Agent Assist 會使用 Speech-to-Text 模型調整功能,以高於其他詞組的頻率辨識特定詞組,藉此提升轉錄品質。本頁面提供指南,說明如何設定語音轉文字轉錄的模型調適功能。
使用 Speech-to-Text 控制台
您只能使用 Speech-to-Text 控制台建立全域片語集。您必須使用 Speech-to-Text API 建立區域片語集。
- 前往 Google Cloud 控制台的「Speech-to-Text」頁面。 前往 Speech-to-Text
- 按一下「模型調整」。
- 按一下「新增資源」add_box。
- 選擇「片語集」資源和 API 版本「V1」,然後填入片語和提升值,並複製「片語集」名稱。
- 按一下 [儲存]。
- 前往 Agent Assist 控制台。
- 按一下「對話商家檔案」,然後選擇要編輯的對話商家檔案。
- 前往「詞組集」部分,然後貼上詞組集名稱。
使用 Speech-to-Text API
- 按照語音辨識操作說明建立詞組集指令碼。
執行下列 Python 指令碼,更新對話設定檔:
# Conversation Profile to update PROJECT_ID = "sample-project" LOCATION = "global" CONVERSATION_PROFILE_ID = "sample-conversation-profile" # Speech model adaptation resource names SPEECH_ADAPTATION_PHRASES = ["projects/sample-project/locations/global/phraseSets/sample-phrase-sets"]
import google.auth from google.auth.transport.requests import AuthorizedSession
scopes=['https://www.googleapis.com/auth/cloud-platform'] credentials, project = google.auth.default( scopes=scopes, quota_project_id=PROJECT_ID, ) session = AuthorizedSession(credentials)
profile_url = f"https://dialogflow.googleapis.com/v2beta1/projects/{PROJECT_ID}/locations/{LOCATION}/conversationProfiles/{CONVERSATION_PROFILE_ID}" get_response = session.get(profile_url) print("Checking for existing ConversationProfile...") print(get_response.status_code) print(get_response.json()) if get_response.status_code == 200: patch_response = session.patch( profile_url, params={ "updateMask": "sttConfig.phraseSets" }, json={ "sttConfig": { "phraseSets": SPEECH_ADAPTATION_PHRASES } } ) print("Updating ConversationProfile...") print(patch_response.status_code) print(patch_response.json())
區域詞組集
雖然 Speech-to-Text 模型調適功能僅支援英文 (en-US
),但您可以使用 Speech-to-Text API 為其他語言區域設定詞組集。如果您要轉錄在這些地區進行的英文對話,這項功能就特別實用。
使用下列範例指令,透過 Speech-to-Text API 建立地區片語集。
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ -H "X-Goog-User-Project: sample_project" \ -d @sample_phrase_sets.json \ "https://us-speech.googleapis.com/v1/projects/sample-project/locations/us/phraseSets"
json 檔案 @sample_phrase_sets.json
包含下列片語集內容:
{ "parent": "projects/sample-project/locations/us", "phraseSetId": "sample-phrase-sets", "phraseSet": { "name": "sample-phrase-sets", "phrases": [ { "value": "Some phrase", "boost": 20 } ] } }
Dialogflow 區域 | 語音轉文字地區 |
---|---|
美國 us-central1 us-east1 us-east7 us-west1 northamerica-northeast1 northamerica-northeast2 |
我們 <0x0 |
eu europe-west1 europe-west2 europe-west3 europe-west4 |
eu <0x0 |
australia-southeast1 asia-northeast1 asia-south1 asia-southeast1 me-west1 global |
全球 <0x0 |