# Set Up Google Speech-to-Text

Source: https://docs.qvoice.net/how-to/google-speech-to-text-setup/

This guide explains how to prepare a Google Cloud project so that QVOICE Platform can transcribe your call recordings and voicemails with **Google Speech-to-Text**, optionally translate those transcripts with **Google Cloud Translation**, and how to confirm that it works.

You need it when you choose **Google Speech-to-Text** as the provider in [AI Transcription](https://docs.qvoice.net/ai-agents/transcription/), for example to transcribe Sinhala or Tamil calls. Google bills the transcriptions to your project.

## How it works

```mermaid
sequenceDiagram
    participant P as QVOICE Platform
    participant B as Your Cloud Storage bucket
    participant S as Google Speech-to-Text
    P->>B: Upload the recording (service account)
    P->>S: Transcribe gs://bucket/recording (Chirp 2, your region)
    S->>B: Read the recording (Speech-to-Text service agent)
    S-->>P: Transcript
    P->>B: Delete the recording
    P->>P: Save the transcript with the recording
```

- The recording stays in your bucket only while it is being transcribed; it is deleted as soon as Google returns the transcript.
- The transcript is stored in QVOICE Platform with the recording. Nothing is kept in Google Cloud.

## What you need

| Item | Details |
| --- | --- |
| A Google Cloud project | With billing enabled. Note its **project ID**. |
| Speech-to-Text API | `speech.googleapis.com`, enabled in that project. |
| Cloud Storage API | `storage.googleapis.com`, enabled in that project (it is enabled by default in new projects). |
| A Cloud Storage bucket | In the **same project**. |
| A service account | With the **Cloud Speech Client** role on the project and the **Storage Object Admin** role on the bucket, and a JSON key. |
| Cloud Translation API (optional) | `translate.googleapis.com`, only if you want to [translate transcripts](https://docs.qvoice.net/how-to/google-speech-to-text-setup/#step-7-recording-translation-optional). The same service account also needs the **Cloud Translation API User** role. |

**Warning:**

Keep the bucket in the same project as the service account. Speech-to-Text reads the audio with its own Google-managed service agent, which can read buckets of its own project by default. A bucket in another project needs extra permissions for that agent and is not covered here.

## Step 1 — Enable the APIs

In the [Google Cloud console](https://console.cloud.google.com/), select the project, open **APIs & Services → Library** and enable **Cloud Speech-to-Text API** and **Cloud Storage API**.

Or with the `gcloud` CLI:

```
gcloud config set project PROJECT_ID
gcloud services enable speech.googleapis.com storage.googleapis.com
```

## Step 2 — Create the bucket

Create the bucket in the region you will pick as **Region** in QVOICE Platform, so the audio is stored and processed in the same place:

| QVOICE Platform Region | Bucket location |
| --- | --- |
| Europe (europe-west4) | `europe-west4` |
| United States (us-central1) | `us-central1` |
| Asia (asia-southeast1) | `asia-southeast1` |

```
gcloud storage buckets create gs://BUCKET_NAME \
  --location=europe-west4 \
  --uniform-bucket-level-access \
  --public-access-prevention
```

Recommended: add a lifecycle rule that deletes objects older than one day. QVOICE Platform already deletes each recording after it is transcribed; the rule cleans up anything left behind if a transcription is interrupted.

```
cat > lifecycle.json <<'EOF'
{"rule": [{"action": {"type": "Delete"}, "condition": {"age": 1}}]}
EOF
gcloud storage buckets update gs://BUCKET_NAME --lifecycle-file=lifecycle.json
```

## Step 3 — Create the service account and its key

1. **IAM & Admin → Service Accounts → Create service account**. Name it, for example, `transcription`.
2. Grant it the **Cloud Speech Client** role (`roles/speech.client`) on the project.
3. Open the bucket → **Permissions → Grant access**, add the service account's email and give it **Storage Object Admin** (`roles/storage.objectAdmin`). It needs to create and delete objects in this bucket only.
4. Open the service account → **Keys → Add key → Create new key → JSON**. A `.json` file is downloaded.

Or with `gcloud`:

```
gcloud iam service-accounts create transcription --display-name="Call transcription"

SA=transcription@PROJECT_ID.iam.gserviceaccount.com

gcloud projects add-iam-policy-binding PROJECT_ID \
  --member="serviceAccount:$SA" --role="roles/speech.client"

gcloud storage buckets add-iam-policy-binding gs://BUCKET_NAME \
  --member="serviceAccount:$SA" --role="roles/storage.objectAdmin"

gcloud iam service-accounts keys create transcription-key.json --iam-account="$SA"
```

**Warning:**

The JSON key gives access to your project. Do not send it by email or chat; paste it directly into QVOICE Platform, then delete the downloaded file. If your organisation blocks service account keys (the `iam.disableServiceAccountKeyCreation` policy), your Google Cloud administrator has to allow it for this project.

## Step 4 — Configure QVOICE Platform

In **Config → Integrations → AI Transcription → Transcription**:

1. **Provider:** select **Google Speech-to-Text**.
2. **Service Account Key (JSON):** paste the whole content of the JSON key file.
3. **Cloud Storage Bucket:** the bucket name, without `gs://` (for example `my-transcription-bucket`).
4. **Language:** the language spoken in your calls, or **Auto-detect** when calls come in more than one language. With Auto-detect each recording is transcribed in its most prevalent language.
5. **Region:** the same region as the bucket.
6. **One speaker per channel:** enable it only if your recordings are stereo with each party on its own channel.
7. **Auto Transcribe Recordings:** enable it to transcribe every new recording automatically.
8. Click **Save**.

After saving, the key field no longer shows the key: it shows the service account's email. That confirms the key was stored. Saving only checks the format of the key and that a bucket is set; it does not contact Google, so permissions are confirmed in Step 8. To keep the stored key when you change other settings later, leave the field empty.

See [AI Transcription](https://docs.qvoice.net/ai-agents/transcription/#google-speech-to-text) for the meaning of each field.

## Step 5 — Turn on transcription for the account

Saving the AI Transcription settings does not show transcripts to users by itself. A reseller administrator or platform super-administrator also has to turn the feature on for the account:

1. Open **Config → Accounts** and find the account.
2. Click the **Transcription** icon in its row.
3. Under **Recordings Transcription**, turn on **Enabled**. Turn on **Auto** too if every new recording should be transcribed.
4. Save.

Without it, users don't get the **Transcript** button on recordings in the web client.

## Step 6 — Live transcription (optional)

To also transcribe calls while they are in progress, in **Config → Integrations → AI Transcription**, section **Live Transcription**:

1. **Transcribe Calls Live:** on.
2. **Mode:** **Automatic** transcribes every call; **Manual** lets the agent start it during the call.
3. **Language:** the language of your calls, or **Auto-detect**. Live, Auto-detect works phrase by phrase, so a call that mixes Sinhala and English is transcribed in both.
4. Click **Save**.

Live transcription uses the same service account and region as recordings. It runs in the web client, so only calls the agent handles there are transcribed live.

## Step 7 — Recording translation (optional)

QVOICE Platform can translate a recording's transcript into another language with **Google Cloud Translation**, using the same service account. Google bills your project per translated character. Translation is only available with Google Speech-to-Text as the provider.

### 7.1 Enable the API and grant the role

1. In the Google Cloud console, open **APIs & Services → Library** and enable **Cloud Translation API**.
2. Open **IAM & Admin → IAM**, find the service account from Step 3 and add the **Cloud Translation API User** role (`roles/cloudtranslate.user`).

Or with `gcloud`:

```
gcloud services enable translate.googleapis.com --project=PROJECT_ID

gcloud projects add-iam-policy-binding PROJECT_ID \
  --member="serviceAccount:transcription@PROJECT_ID.iam.gserviceaccount.com" \
  --role="roles/cloudtranslate.user"
```

You don't need a new key: the key you pasted in Step 4 is used. Role changes can take a few minutes to apply.

### 7.2 Turn it on in QVOICE Platform

In the same AI Transcription screen, section **Recording Translation**:

1. **Translate Transcripts:** on.
2. **Default Language:** the language users translate into most often. The player offers it first.
3. **Auto Translate** (optional): translates every automatic transcript into the default language as soon as it is ready, so the player opens it already translated. Google bills each one, whether or not anyone opens the recording. Leave it off to translate only when a user asks for it.
4. Click **Check**. QVOICE Platform translates a test word with the stored key and shows **Works with** the service account and project, or what is missing.
5. Click **Save**.

If you pasted a new key in the same visit, save it first; the check uses the stored key.

### 7.3 What the check means

| Message | What to do |
| --- | --- |
| The Cloud Translation API is not enabled in the project of this service account. | Enable **Cloud Translation API** in the project shown (7.1). If you have just enabled it, wait a few minutes and check again. |
| The service account is not allowed to translate. Give it the Cloud Translation API User role (roles/cloudtranslate.user). | Grant the role to the service account (7.1), wait a few minutes and check again. |
| Google did not accept the service account key. | The key was deleted or disabled in Google Cloud. Create a new key (Step 3) and paste it in Step 4. |
| There is no Google service account saved for this account. | Save the Google Speech-to-Text settings with a key first (Step 4). |

Under the message, the line starting with **Google:** is Google's own error text, which names the project and the missing permission.

### 7.4 Where users translate

- **Reports → Call Recordings:** play a recording, and use the **Translate…** list next to the transcript to pick any of the languages Google supports (type to search). The transcript is shown with the note "Machine translation to *language* from *language*", and **Show original** goes back. Copy and `.txt` download use the language being shown.
- **Transcript Search** report: the transcript panel has the same **Translate…** list. With **Auto Translate** on, searching in the default language also finds calls by their translation; those results are marked **Matched in the *language* translation**.

Each translation is saved with the recording, so opening it again does not translate (or bill) it a second time. Transcribing the recording again discards its saved translations.

## Step 8 — Confirm it works

1. Make a test call of at least 30 seconds with call recording on, speaking in the configured language.
2. In the portal, open **Reports → Call Recordings**, play that recording and request its transcript (or wait for it, if **Auto Transcribe Recordings** is on). The transcript, split by speaker, appears with the recording.
3. In the Google Cloud console:
   - **APIs & Services → Cloud Speech-to-Text API → Metrics** shows the requests.
   - The bucket is **empty** again once the transcript is back.
4. If you turned on translation, open the recording's transcript and pick a language in **Translate…**. **APIs & Services → Cloud Translation API → Metrics** shows the request.
