Skip to content

Latest commit

 

History

History

README.md

Python console app

This sample demonstrates various forms of speech recognition, speech synthesis, translation and transcription using the Speech SDK for Python.

Prerequisites

Build the sample

By using the Cognitive Services Speech SDK you acknowledge its license, see Speech SDK license agreement.

  • Install the Speech SDK Python package in your Python interpreter, typically by executing the command

    pip install azure-cognitiveservices-speech

    in a terminal.

  • For transcription sample, install the Scipy package in your Python interpreter by executing the command

    pip install scipy
  • To authenticate using an AAD token credential, install the azure-identity package in your Python interpreter by executing the command

    pip install azure-identity
  • For AAD token authentication, you need to set up a custom domain endpoint for your Speech resource. Update the following setting in the sample files:

    • YourEndpointWithCustomDomain: replace with your Speech resource custom domain endpoint, such as https://your-custom-domain.cognitiveservices.azure.com/
    • For details on setting up a custom domain with private links, see Create a custom domain name
  • Download the sample code to your development PC.

  • To tailor the sample to your configuration, use search and replace across the whole sample directory to update the following strings:

    • YourSubscriptionKey: replace with your subscription key.
    • https://YourServiceRegion.api.cognitive.microsoft.com: replace with the endpoint for your Speech resource. You can find this endpoint in the Azure Portal under your Speech resource's "Keys and Endpoint" section.
    • The following settings apply to keyword-triggered recognition:
      • YourKeywordRecognitionModelFile.table: replace with the location of your keyword recognition model file.
      • YourKeyword: replace with the phrase your keyword recognition model triggers on.
    • Some samples require audio files to be present. Put appropriate audio files somewhere on your file system and adapt the paths in the Python source files.

Run the samples

To run the app, navigate to the samples/python/console directory in your local copy of the samples repository. Start the app with the command

python3 main.py

Depending on your platform, the Python 3 executable might also just be called python.

The app displays a menu that you can navigate using your keyboard. Choose the scenarios that you're interested in.

References