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.


Speech service has several REST APIs for Speech-to-text and Text-to-speech.

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.

  1. In a browser, go to the Swagger specification for your region:
  2. On that page, click API definition, and click Swagger. Copy the URL of the page that appears.
  3. In a new browser, go to
  4. Click File, click Import URL, paste the URL, and click OK.
  5. Click Generate Client and select python. The client library downloads to your computer in a .zip file.
  6. Extract everything from the download. You might use tar -xf to extract everything.
  7. Install the extracted module into your Python environment:
    pip install path/to/package/python-client
  8. 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.

Next steps