本頁面說明當您將轉錄要求傳送至 Speech-to-Text 時,如何要求強化版語音辨識模型。
目前有兩種強化版模型:語音通話和影片。這些模型經過最佳化,可更準確地轉錄這些特定來源的音訊資料。請參閱支援的語言頁面,瞭解您的語言是否有適用的強化版模型。
Google 會根據透過資料記錄功能收集到的資料,建立及改善強化版模型。雖然不加入資料記錄計畫也能使用強化版模型,但加入後可協助 Google 改善這些模型,還能享有使用折扣。
如要使用強化版辨識模型,請在 RecognitionConfig 中設定下列欄位:
- 將
useEnhanced
設為true
。 - 在
model
欄位中傳遞phone_call
或video
字串。
語音轉文字支援所有語音辨識方法的強化模型:speech:recognize
speech:longrunningrecognize
和「串流」。
下列程式碼範例示範如何要求針對轉錄要求使用強化版模型。
通訊協定
如要瞭解完整的詳細資訊,請參閱 speech:recognize
API 端點。
如要執行同步語音辨識,請提出 POST
要求並提供適當的要求內容。以下為使用 curl
的 POST
要求示例。這個範例使用 Google Cloud CLI 產生存取權杖。如需安裝 gcloud CLI 的操作說明,請參閱快速入門導覽課程。
curl -s -H "Content-Type: application/json" \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ https://speech.googleapis.com/v1/speech:recognize \ --data '{ "config": { "encoding": "LINEAR16", "languageCode": "en-US", "enableWordTimeOffsets": false, "enableAutomaticPunctuation": true, "model": "phone_call", "useEnhanced": true }, "audio": { "uri": "gs://cloud-samples-tests/speech/commercial_mono.wav" } }'
如需設定要求內容的更多資訊,請參閱 RecognitionConfig
參考說明文件。
如果要求成功,伺服器會傳回 200 OK
HTTP 狀態碼與 JSON 格式的回應:
{ "results": [ { "alternatives": [ { "transcript": "Hi, I'd like to buy a Chromecast. I was wondering whether you could help me with that.", "confidence": 0.8930228 } ], "resultEndTime": "5.640s" }, { "alternatives": [ { "transcript": " Certainly, which color would you like? We are blue black and red.", "confidence": 0.9101991 } ], "resultEndTime": "10.220s" }, { "alternatives": [ { "transcript": " Let's go with the black one.", "confidence": 0.8818244 } ], "resultEndTime": "13.870s" }, { "alternatives": [ { "transcript": " Would you like the new Chromecast Ultra model or the regular Chromecast?", "confidence": 0.94733626 } ], "resultEndTime": "18.460s" }, { "alternatives": [ { "transcript": " Regular Chromecast is fine. Thank you. Okay. Sure. Would you like to ship it regular or Express?", "confidence": 0.9519095 } ], "resultEndTime": "25.930s" }, { "alternatives": [ { "transcript": " Express, please.", "confidence": 0.9101229 } ], "resultEndTime": "28.260s" }, { "alternatives": [ { "transcript": " Terrific. It's on the way. Thank you. Thank you very much. Bye.", "confidence": 0.9321616 } ], "resultEndTime": "34.150s" } ] }
Go
如要瞭解如何安裝及使用 Speech-to-Text 的用戶端程式庫,請參閱這篇文章。 詳情請參閱 Speech-to-Text Go API 參考說明文件。
如要向語音轉文字服務進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。
Python
如要瞭解如何安裝及使用 Speech-to-Text 的用戶端程式庫,請參閱這篇文章。 詳情請參閱 Speech-to-Text Python API 參考說明文件。
如要向語音轉文字服務進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。
Java
如要瞭解如何安裝及使用 Speech-to-Text 的用戶端程式庫,請參閱這篇文章。 詳情請參閱 Speech-to-Text Java API 參考說明文件。
如要向語音轉文字服務進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。
Node.js
如要瞭解如何安裝及使用 Speech-to-Text 的用戶端程式庫,請參閱這篇文章。 詳情請參閱 Speech-to-Text Node.js API 參考說明文件。
如要向語音轉文字服務進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。
其他語言
C#: 請按照用戶端程式庫頁面的 C# 設定說明操作, 然後前往 .NET 適用的 Speech-to-Text 參考說明文件。
PHP: 請按照用戶端程式庫頁面的 PHP 設定說明 操作,然後前往 PHP 適用的 Speech-to-Text 參考文件。
Ruby: 請按照用戶端程式庫頁面的Ruby 設定說明操作, 然後前往 Ruby 適用的 Speech-to-Text 參考說明文件。
後續步驟
瞭解如何提出同步轉錄要求。