Swagger 文档Swagger documentation

语音服务提供了一个 Swagger 规范,用于与少量 REST API 交互,这些 REST API 用于导入数据、创建模型、测试模型准确性、创建自定义终结点、排列批量听录以及管理订阅。The Speech service offers a Swagger specification to interact with a handful of REST APIs used to import data, create models, test model accuracy, create custom endpoints, queue up batch transcriptions, and manage subscriptions. 可使用这些 API 以编程方式完成通过自定义语音识别门户提供的大部分操作。Most operations available through the Custom Speech portal can be completed programmatically using these APIs.

备注

支持将语音转文本和文本转语音操作作为 REST API,而后者记录在 Swagger 规范中。Both Speech-to-Text and Text-to-Speech operations are supported available as REST APIs, which are in turn documented in the Swagger specification.

从 Swagger 规范生成代码Generating code from the Swagger specification

Swagger 规范包含可快速测试各种路径的选项。The Swagger specification has options that allow you to quickly test for various paths. 但有时需要为所有路径生成代码,从而创建可基于未来的解决方案的单个调用库。However, sometimes it's desirable to generate code for all paths, creating a single library of calls that you can base future solutions on. 让我们看看生成 Python 库的过程。Let's take a look at the process to generate a Python library.

你需要将 Swagger 设置为与语音服务订阅相同的区域。You'll need to set Swagger to the same region as your Speech service subscription. 可在 Azure 门户中的语音服务资源下确认区域。You can confirm your region in the Azure portal under your Speech service resource. 有关受支持区域的完整列表,请参阅区域For a complete list of supported regions, see regions.

  1. 转到 https://editor.swagger.ioGo to https://editor.swagger.io
  2. 单击“文件”,然后单击“导入” Click File, then click Import
  3. 输入 Swagger URL,包括语音服务订阅的区域 https://<your-region>.cris.azure.cn/docs/v2.0/swaggerEnter the swagger URL including the region for your Speech service subscription https://<your-region>.cris.azure.cn/docs/v2.0/swagger
  4. 单击“生成客户端”,然后选择 PythonClick Generate Client and select Python
  5. 保存客户端库Save the client library

可以使用通过 GitHub 上的语音服务示例生成的 Python 库。You can use the Python library that you generated with the Speech service samples on GitHub.

参考文档Reference docs

后续步骤Next steps