Document
设置 Speech-to-Text

设置 Speech-to-Text

Speech-to-Text 是一种由 Google 的人工智能 (AI) 技术提供支持的 API。您可以将音频数据发送到 Speech-to-Text,然后接收该音频数据的文字转录作为响应。 如需详细了解如何构造 Speech-to-Text 请求,请参阅请求页面。 概览 您必须先在 Goo

Related articles

How to Draw a Storm Dell 7 Best VPNs for Call of Duty in 2024: PC, Xbox, PS5, Mobile Cedric Weather and Atmospheric Water

Speech-to-Text 是一种由 Google 的人工智能 (AI) 技术提供支持的 API。您可以将音频数据发送到 Speech-to-Text,然后接收该音频数据的文字转录作为响应。

如需详细了解如何构造 Speech-to-Text 请求,请参阅请求页面。

概览

您必须先在 Google Cloud 控制台中启用该 API,然后才能开始向 Speech-to-Text 发送请求。本页面中的步骤将引导您完成以下操作:

  • 在项目上启用 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. 如果您创建新项目,则系统会提示您将一个结算账号关联到该项目。如果您使用的是现有项目,请确保已启用结算功能。

    了解如何确认项目已启用结算功能。

    注意:您必须启用结算功能才能使用 Speech-to-Text API,但除非您超出免费配额,否则不需要支付费用。如需了解详情,请参阅价格页面。

  4. 选择项目并将其关联到结算账号后,您就可以启用 Speech-to-Text API。转到页面顶部的搜索产品和资源栏,然后输入“speech”。从结果列表中选择 Cloud Speech – to – text api 。

  5. 要在不将其与项目关联的情况下试用 Speech-to-Text,请选择试用此 API 选项。如需启用 Speech-to-Text API 以用于您的项目,请点击启用。

  6. ( 可选)启用数据日志记录。选择启用数据日志记录,即表示您允许 Google 记录您发送到 Speech – to – text 的所有音频数据。此数据将用于改进 speech – to – text 模型。选择启用数据日志记录功能的用户可以获享更低的产品价格。如需了解详情,请参阅价格和数据日志记录条款及条件页面 。

可选:创建 Cloud Storage 存储桶

如需转录超过 60 秒的音频或文件大小大于 10 MB 的音频,您必须先将音频数据存储在 Cloud Storage 存储桶中,然后才能使用 Speech-to-Text 进行转录。以下步骤将引导您完成创建新存储桶的过程。

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

    Go to Buckets page

  • Click create bucket.
  • 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.

    • For Choose where to store your data, do the follow :

      • select alocation type option.
      • select alocation option.
    • For Choose a default storage class for your data, select a storage class.

    • ForChoose how to control access to objects, select anAccess control option .
    • ForAdvanced settings (optional), specify
      an encryption method,
      a retention policy,
      or bucket labels.
  • Click create.
  • 停用 Speech-to-Text API

    如果您将来不再需要使用 Speech-to-Text API,请完成以下步骤。

    1. 导航到 is 信息中心,然后点击 Google Cloud is 信息中心,然后点击 信息中心,然后点击 API 框中的转到 API 概览链接 。
    2. 选择 Cloud Speech – to – text api 。
    3. 点击 Cloud Speech – to – text api 页面顶部的停用 API 按钮 。

    后续步骤

    了解如何使用客户端库、gcloud、命令行或 Speech-to-Text 界面向 Speech-to-Text API 发送转写请求。