Cloud Speech-to-Text API 會以音訊資料做為輸入內容,並使用 Google 的 AI 技術輸出文字轉錄稿,將語音轉換為文字。本頁說明如何為專案設定 Cloud Speech-to-Text API,以便開始呼叫 API。
本文涵蓋下列主題:
- 為 Google Cloud 專案啟用及停用 Cloud Speech-to-Text API
- 啟用 Cloud Speech-to-Text 的計費功能
- 選用:建立新的 Google Cloud 儲存空間 bucket,儲存大型音訊資料
本文不會說明如何使用 Cloud Speech-to-Text API 開始傳送及接收要求。如要瞭解如何開始將 Cloud Speech-to-Text 整合至實際程式碼,請參閱總覽頁面。
事前準備
存取這項服務的方式有兩種:使用 REST API 或Google Cloud 控制台。
本指南將說明開始將要求傳送至 REST API 的必要步驟。如果您是程式設計新手,建議先完成 Google Cloud「平台」中的逐步控制台教學課程,再開始執行這些步驟。
為 Google Cloud 專案啟用 Cloud Speech-to-Text API
登入 Google Cloud 控制台。
如果您建立新專案,系統會提示您將帳單帳戶連結到該專案;如果您使用現有專案,請確認計費功能已啟用。
啟用 Cloud Speech-to-Text API。按一下頁面頂端的「Search products and resources」(搜尋產品和資源) 文字欄位,然後輸入「speech」,然後從結果清單中選取「Cloud Speech-to-Text API」。
如要啟用 Cloud Speech-to-Text API,以便搭配專案使用,請按一下「啟用」。如要試用 Cloud Speech-to-Text,但不想將這項工具連結到專案,請按一下「Try this API」(試用這個 API)。
選用步驟:(僅限 API V1) 啟用資料記錄功能。啟用資料記錄功能後,Google 即可記錄您傳送至 Cloud Speech-to-Text 的任何音訊資料。這類資料會用於提升 Cloud 語音轉文字模型的品質。選擇啟用資料記錄功能的使用者,可享有較低的價格。詳情請參閱定價和資料記錄條款及細則頁面。
選用:建立 Cloud Storage bucket
如要轉錄超過 60 秒的音訊,或檔案大小超過 10 MB,必須先將音訊資料儲存在 Cloud Storage 儲存空間,才能使用 Cloud Speech-to-Text 轉錄。
如要建立新的 Cloud Storage bucket:
- In the Google Cloud console, go to the Cloud Storage Buckets page.
- Click Create.
- On the Create a bucket page, enter your bucket information. To go to the next
step, click Continue.
- For Name your bucket, enter a unique bucket name. Don't include sensitive information in the bucket name, because the bucket namespace is global and publicly visible.
-
In the Choose where to store your data section, do the following:
- Select a Location type.
- Choose a location where your bucket's data is permanently stored from the Location type drop-down menu.
- If you select the dual-region location type, you can also choose to enable turbo replication by using the relevant checkbox.
- To set up cross-bucket replication, select
Add cross-bucket replication via Storage Transfer Service and
follow these steps:
Set up cross-bucket replication
- In the Bucket menu, select a bucket.
In the Replication settings section, click Configure to configure settings for the replication job.
The Configure cross-bucket replication pane appears.
- To filter objects to replicate by object name prefix, enter a prefix that you want to include or exclude objects from, then click Add a prefix.
- To set a storage class for the replicated objects, select a storage class from the Storage class menu. If you skip this step, the replicated objects will use the destination bucket's storage class by default.
- Click Done.
-
In the Choose how to store your data section, do the following:
- Select a default storage class for the bucket or Autoclass for automatic storage class management of your bucket's data.
- To enable hierarchical namespace, in the Optimize storage for data-intensive workloads section, select Enable hierarchical namespace on this bucket.
- In the Choose how to control access to objects section, select whether or not your bucket enforces public access prevention, and select an access control method for your bucket's objects.
-
In the Choose how to protect object data section, do the
following:
- Select any of the options under Data protection that you
want to set for your bucket.
- To enable soft delete, click the Soft delete policy (For data recovery) checkbox, and specify the number of days you want to retain objects after deletion.
- To set Object Versioning, click the Object versioning (For version control) checkbox, and specify the maximum number of versions per object and the number of days after which the noncurrent versions expire.
- To enable the retention policy on objects and buckets, click the Retention (For compliance) checkbox, and then do the following:
- To enable Object Retention Lock, click the Enable object retention checkbox.
- To enable Bucket Lock, click the Set bucket retention policy checkbox, and choose a unit of time and a length of time for your retention period.
- To choose how your object data will be encrypted, expand the Data encryption section (), and select a Data encryption method.
- Select any of the options under Data protection that you
want to set for your bucket.
- Click Create.
- 前往 Google Cloud 資訊主頁,然後按一下「前往 API 總覽」。
- 選取「Cloud Speech-to-Text API」。
- 點選「停用 API」。
停用 Cloud Speech-to-Text API
如果專案不再需要使用 Cloud Speech-to-Text API,請按照下列步驟操作:
後續步驟
瞭解如何使用用戶端程式庫、gcloud、指令列或 Speech-to-Text 使用者介面,將語音轉錄要求傳送至 Cloud Speech-to-Text API。