設定 Speech-to-Text

Speech-to-Text API 採用 Google 的人工智慧 (AI) 技術,您將音訊資料傳送至 Speech-to-Text,然後在回應中收到音訊資料的文字轉錄內容。

如要進一步瞭解如何建構 Speech-to-Text 要求,請參閱要求頁面。

總覽

如要開始傳送 Speech-to-Text 要求,請先在 Google Cloud 控制台中啟用 API。本頁的步驟會引導您完成下列動作:

  • 在專案中啟用 Speech-to-Text。
  • 確認已啟用 Speech-to-Text 的計費功能。
  • (選用) 建立新的 Google Cloud Storage 值區,以儲存音訊資料。

事前準備

存取這項服務的方式有兩種:使用 REST API 或 Speech-to-Text 控制台。我們提供程式碼範例,說明如何向 REST API 提出要求及接收回應。如要瞭解如何使用這些範例,請參閱 Speech-to-Text 的快速入門導覽課程使用指南。如要使用 Speech-to-Text,但不想編寫太多程式碼,可以改用 Cloud Speech-to-Text 控制台

本指南將逐步說明開始傳送 REST API 要求所需的步驟。如果您是程式設計新手,建議先完成 Google Cloud Platform 的逐步控制台內教學課程,再開始進行本快速入門導覽課程。

為 Speech-to-Text 設定專案 Google Cloud

  1. 登入 Google Cloud 主控台

  2. 前往專案選取器頁面

    您可以選擇現有專案或建立新專案。如要進一步瞭解如何建立專案,請參閱「建立及管理專案」一文。

  3. 如果您建立新專案,系統會提示您將帳單帳戶連結至該專案。如果您使用現有專案,請確認已啟用帳單服務。

    瞭解如何確認專案已啟用計費功能

  4. 選取專案並連結至帳單帳戶後,即可啟用 Speech-to-Text API。前往頁面頂端的「搜尋產品和資源」列,然後輸入「speech」。從結果清單中選取「Cloud Speech-to-Text API」

  5. 如要試用 Speech-to-Text,但不想將其連結至專案,請選擇「TRY THIS API」選項。如要啟用 Speech-to-Text API,以便在專案中使用,請按一下「啟用」

  6. (選用) 啟用資料記錄功能。選擇啟用資料記錄功能,即表示允許 Google 記錄您傳送至 Speech-to-Text 的任何音訊資料。這類資料會用於提升語音轉文字模型的品質。選擇啟用資料記錄功能的使用者,可享有較低的價格。詳情請參閱定價和資料記錄條款及細則頁面。

選用:建立 Cloud Storage bucket

如要轉錄超過 60 秒的音訊,或檔案大小超過 10 MB,必須先將音訊資料儲存在 Cloud Storage bucket 中,才能使用 Speech-to-Text 轉錄。下列步驟將逐步說明如何建立新的 bucket。

  • In the Google Cloud console, go to the Cloud Storage Buckets page.

    Go to Buckets

  • Click Create.
  • On the Create a bucket page, enter your bucket information. To go to the next step, click Continue.
    1. 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.
    2. In the Choose where to store your data section, do the following:
      1. Select a Location type.
      2. Choose a location where your bucket's data is permanently stored from the Location type drop-down menu.
      3. To set up cross-bucket replication, select Add cross-bucket replication via Storage Transfer Service and follow these steps:

        Set up cross-bucket replication

        1. In the Bucket menu, select a bucket.
        2. 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.
    3. In the Choose how to store your data section, do the following:
      1. Select a default storage class for the bucket or Autoclass for automatic storage class management of your bucket's data.
      2. To enable hierarchical namespace, in the Optimize storage for data-intensive workloads section, select Enable hierarchical namespace on this bucket.
    4. 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.
    5. 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.
  • Click Create.
  • 停用 Speech-to-Text API

    如果您日後不再需要使用 Speech-to-Text API,請完成下列步驟。

    1. 前往 Google Cloud 資訊主頁,然後點按「API」方塊中的「前往 API 總覽」連結。
    2. 選取「Cloud Speech-to-Text API」
    3. 按一下 Cloud Speech-to-Text API 頁面頂端的「停用 API」按鈕。

    後續步驟

    瞭解如何使用用戶端程式庫gcloud指令列Speech-to-Text UI,將轉錄要求傳送至 Speech-to-Text API。