Generate a REST API client library for the Speech-to-text REST API v3.0
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. Most operations available through the Custom Speech area of the Speech Studio can be completed programmatically using these APIs.
However only Speech-to-text REST API v3.0 is documented in the Swagger specification. See the documents referenced in the previous paragraph for the information on all other Speech Services REST APIs.
Generating code from the Swagger specification
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. Let's take a look at the process to generate a Python library.
You'll need to set Swagger to the region of your Speech resource. You can confirm the region in the Overview part of your Speech resource settings in Azure portal. The complete list of supported regions is available here.
- In a browser, go to the Swagger specification for your region:
- On that page, click API definition, and click Swagger. Copy the URL of the page that appears.
- In a new browser, go to https://editor.swagger.io
- Click File, click Import URL, paste the URL, and click OK.
- Click Generate Client and select python. The client library downloads to your computer in a
- Extract everything from the download. You might use
tar -xfto extract everything.
- Install the extracted module into your Python environment:
pip install path/to/package/python-client
- The installed package is named
swagger_client. Check that the installation has worked:
python -c "import swagger_client"
You can use the Python library that you generated with the Speech service samples on GitHub.
Submit and view feedback for