Quickstart: Set up the development environment

Choose your target environment

This guide shows how to install the Speech SDK for the .NET Framework (Windows). If you just want the package name to get started on your own, run Install-Package Microsoft.CognitiveServices.Speech in the NuGet console.

Important

By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. For more information, see:

Prerequisites

This quickstart requires:

Create a Visual Studio project and install the Speech SDK

You need to install the Speech SDK NuGet package so you can reference it in your code. To do that, you might first need to create a helloworld project. If you already have a project with the .NET desktop development workload available, you can use that project and skip to Use NuGet Package Manager to install the Speech SDK.

Create a helloworld project

  1. Open Visual Studio 2019.

  2. In the Start window, select Create a new project.

  3. In the Create a new project window, choose Console App (.NET Framework), and then select Next.

  4. In the Configure your new project window, enter helloworld in Project name, choose or create the directory path in Location, and then select Create.

  5. From the Visual Studio menu bar, select Tools > Get Tools and Features. This step opens Visual Studio Installer and displays the Modifying dialog.

  6. Check whether the .NET desktop development workload is available. If the workload hasn't been installed, select the check box next to it, and then select Modify to start the installation. It might take a few minutes to download and install.

    If the check box next to .NET desktop development is already selected, select Close to close the dialog.

    Screenshot that shows enabling .NET desktop development.

  7. Close Visual Studio Installer.

Use NuGet Package Manager to install the Speech SDK

  1. In Solution Explorer, right-click the helloworld project, and then select Manage NuGet Packages to show NuGet Package Manager.

  2. In the upper-right corner, find the Package Source drop-down box, and make sure that nuget.org is selected.

    Screenshot that shows NuGet Package Manager.

  3. In the upper-left corner, select Browse.

  4. In the search box, type Microsoft.CognitiveServices.Speech and select Enter.

  5. From the search results, select the Microsoft.CognitiveServices.Speech package, and then select Install to install the latest stable version.

    Screenshot that shows installing the Microsoft.CognitiveServices.Speech NuGet package.

  6. Accept all agreements and licenses to start the installation.

    After the package is installed, a confirmation appears in the Package Manager Console window.

Choose target architecture

To build and run the console application, create a platform configuration that matches your computer's architecture.

  1. From the menu bar, select Build > Configuration Manager. The Configuration Manager dialog appears.

  2. In the Active solution platform drop-down box, select New. The New Solution Platform dialog appears.

    Screenshot that shows the Configuration Manager dialog.

  3. In the Type or select the new platform drop-down box:

    • If you're running 64-bit Windows, select x64.
    • If you're running 32-bit Windows, select x86.
  4. Select OK and then Close.

Next steps

Choose your target environment

This guide shows how to install the Speech SDK for Linux.

Important

By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. For more information, see:

System requirements

See the system requirements and setup instructions for Linux.

Install the Speech SDK

Use the following procedure to download and install the SDK. The steps include downloading the required libraries and header files as a .tar file from https://aka.ms/csspeech/linuxbinary.

  1. Choose a directory to which the Speech SDK files should be extracted, and set the SPEECHSDK_ROOT environment variable to point to that directory. This variable makes it easy to refer to the directory in future commands.

    For example, if you want to use the directory speechsdk in your home directory, use a command like the following:

    export SPEECHSDK_ROOT="$HOME/speechsdk"
    
  2. Create the directory if it doesn't exist yet:

    mkdir -p "$SPEECHSDK_ROOT"
    
  3. Download and extract the .tar.gz archive that contains the Speech SDK binaries:

    wget -O SpeechSDK-Linux.tar.gz https://aka.ms/csspeech/linuxbinary
    tar --strip 1 -xzf SpeechSDK-Linux.tar.gz -C "$SPEECHSDK_ROOT"
    
  4. Validate the contents of the top-level directory of the extracted package:

    ls -l "$SPEECHSDK_ROOT"
    

    The directory listing should contain the third-party notice and license files. The listing should also contain an include directory that holds header (.h) files and a lib directory that holds libraries for arm32, arm64, x64, and x86.

    Path Description
    license.md License
    ThirdPartyNotices.md Third-party notices
    REDIST.txt Redistribution notice
    include Required header files for C++
    lib/arm32 Native library for ARM32 required to link your application
    lib/arm64 Native library for ARM64 required to link your application
    lib/x64 Native library for x64 required to link your application
    lib/x86 Native library for x86 required to link your application

Next steps

Choose your target environment

This guide shows how to install the Speech SDK for Java. If you just want the package name to get started on your own, the Java SDK is not available in the Maven central repository. Whether you're using Gradle or a pom.xml dependency file, you need to add a custom repository that points to https://azureai.azureedge.net/maven/. (See below for the package name.)

Important

By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. For more information, see:

Supported operating systems

The Java Speech SDK package is available for these operating systems:

Prerequisites

Gradle configurations

Gradle configurations require both a custom repository and an explicit reference to the .jar dependency extension:

// build.gradle

repositories {
    maven {
        url "https://azureai.azureedge.net/maven/"
    }
}

dependencies {
    implementation group: 'com.microsoft.cognitiveservices.speech', name: 'client-sdk', version: "1.21.0", ext: "jar"
}

Create an Eclipse project and install the Speech SDK

  1. Start Eclipse.

  2. In Eclipse Launcher, in the Workspace box, enter the name of a new workspace directory. Then select Launch.

    Screenshot of Eclipse Launcher.

  3. In a moment, the main window of the Eclipse IDE appears. Close the Welcome screen if one is present.

  4. From the Eclipse menu bar, create a new project by selecting File > New > Project.

  5. The New Project dialog appears. Select Java Project, and then select Next.

    Screenshot of the New Project dialog, with Java Project highlighted.

  6. The New Java Project wizard starts. In the Project name field, enter quickstart. Choose JavaSE-1.8 as the execution environment. Select Finish.

    Screenshot of the New Java Project wizard, with selections for creating a Java project.

  7. If the Open Associated Perspective? window appears, select Open Perspective.

  8. In Package Explorer, right-click the quickstart project. Select Configure > Convert to Maven Project from the shortcut menu.

    Screenshot of Package Explorer and the commands for converting to a Maven project.

  9. The Create new POM window appears. In the Group Id field, enter com.microsoft.cognitiveservices.speech.samples. In the Artifact Id field, enter quickstart. Then select Finish.

    Screenshot of the window for creating a new POM.

  10. Open the pom.xml file and edit it:

    • At the end of the file, before the closing tag </project>, create a repositories element with a reference to the Maven repository for the Speech SDK:

      <repositories>
        <repository>
          <id>maven-cognitiveservices-speech</id>
          <name>Microsoft Cognitive Services Speech Maven Repository</name>
          <url>https://csspeechstorage.blob.core.windows.net/maven/</url>
        </repository>
      </repositories>
      
    • Add a dependencies element, with Speech SDK version 1.21.0 as a dependency:

      <dependencies>
        <dependency>
          <groupId>com.microsoft.cognitiveservices.speech</groupId>
          <artifactId>client-sdk</artifactId>
          <version>1.21.0</version>
        </dependency>
      </dependencies>
      
    • Save the changes.

Next steps

This guide shows how to install the Speech SDK for Python. If you just want the package name to get started on your own, run pip install azure-cognitiveservices-speech.

Important

By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. For more information, see:

Supported operating systems

The Python Speech SDK package is available for these operating systems:

Prerequisites

Before you install the Python Speech SDK, make sure you have the following prerequisites:

Important

Make sure that packages of the same platform (x64 or x86) are installed. For example, if you install the x64 redistributable package, then you need to install the x64 package for Python.

Install the Speech SDK from PyPI

The Python Speech SDK is available as a Python Package Index (PyPI) module. For more information, see azure-cognitiveservices-speech . The Python Speech SDK is compatible with Windows, Linux, and macOS. Install a version of Python from 3.7 to 3.10.

Before you install the Python Speech SDK, make sure to satisfy the system requirements and prerequisites.

To install the Speech SDK, run this command in a terminal.

pip install azure-cognitiveservices-speech

If you're on macOS and run into install issues, you may need to run this command first.

python3 -m pip install --upgrade pip

Now you can import the Speech SDK into your Python project.

import azure.cognitiveservices.speech as speechsdk

Install the Speech SDK by using Visual Studio Code

Before you install the Python Speech SDK, be sure to satisfy the system requirements and prerequisites listed earlier.

  1. Download and install Visual Studio Code.

  2. Run Visual Studio Code and install the Python extension:

    1. Select File > Preferences > Extensions.
    2. Search for Python, find the Python extension for Visual Studio Code published by Microsoft, and then select Install.

    Screenshot that shows selections for installing the Python extension.

  3. Select Terminal > New Terminal to open a terminal within Visual Studio Code.

  4. At the terminal prompt, run the command python -m pip install azure-cognitiveservices-speech to install the Speech SDK Python package.

For more information about Visual Studio Code and Python, see the Visual Studio Code documentation and the Visual Studio Code Python tutorial.

Support and updates

Updates to the Python Speech SDK package are distributed via PyPI and announced in the release notes.

To upgrade to the latest Speech SDK, run this command in a terminal:

pip install --upgrade azure-cognitiveservices-speech

You can check which Python Speech SDK version is currently installed by inspecting the azure.cognitiveservices.speech.__version__ variable. For example, run this command in a terminal:

pip list

If you have any problems, or you're missing a feature, see Support and help options.

Next steps

This guide shows how to install the Speech SDK for Go on Linux.

Important

By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. For more information, see:

System requirements

Before you install the Speech SDK for Go, you need:

Install the Speech SDK

Use the following procedure to download and install the SDK. The steps include downloading the required libraries and header files as a .tar file from https://aka.ms/csspeech/linuxbinary.

  1. Choose a directory to which the Speech SDK files should be extracted, and set the SPEECHSDK_ROOT environment variable to point to that directory. This variable makes it easy to refer to the directory in future commands.

    For example, if you want to use the directory speechsdk in your home directory, use a command like the following:

    export SPEECHSDK_ROOT="$HOME/speechsdk"
    
  2. Create the directory if it doesn't exist yet:

    mkdir -p "$SPEECHSDK_ROOT"
    
  3. Download and extract the .tar.gz archive that contains the Speech SDK binaries:

    wget -O SpeechSDK-Linux.tar.gz https://aka.ms/csspeech/linuxbinary
    tar --strip 1 -xzf SpeechSDK-Linux.tar.gz -C "$SPEECHSDK_ROOT"
    
  4. Validate the contents of the top-level directory of the extracted package:

    ls -l "$SPEECHSDK_ROOT"
    

    The directory listing should contain the third-party notice and license files. The listing should also contain an include directory that holds header (.h) files and a lib directory that holds libraries for arm32, arm64, x64, and x86.

    Path Description
    license.md License
    ThirdPartyNotices.md Third-party notices
    REDIST.txt Redistribution notice
    include Required header files for C++
    lib/arm32 Native library for ARM32 required to link your application
    lib/arm64 Native library for ARM64 required to link your application
    lib/x64 Native library for x64 required to link your application
    lib/x86 Native library for x86 required to link your application

Configure the Go environment

The following steps enable your Go environment to find the Speech SDK. In both steps, replace <architecture> with the processor architecture of your CPU. This will be x86, x64, arm32, or arm64.

  1. Because the bindings rely on cgo, you need to set the environment variables so Go can find the SDK.

    export CGO_CFLAGS="-I$SPEECHSDK_ROOT/include/c_api"
    export CGO_LDFLAGS="-L$SPEECHSDK_ROOT/lib/<architecture> -lMicrosoft.CognitiveServices.Speech.core"
    
  2. To run applications and the SDK, you need to tell the operating system where to find the libraries.

    export LD_LIBRARY_PATH="$SPEECHSDK_ROOT/lib/<architecture>:$LD_LIBRARY_PATH"
    

Next steps


Choose your target environment

This guide shows how to install the Speech SDK for JavaScript for use with a webpage.

Important

By downloading any of the Azure Cognitive Services Speech SDKs, you acknowledge its license. For more information, see:

Create a folder

Create a new, empty folder. If you want to host the sample on a web server, make sure that the web server can access the folder.

Unpack the Speech SDK for JavaScript into the new folder

Download the Speech SDK as a .zip package and unpack it into the newly created folder. Five files are unpacked:

  • microsoft.cognitiveservices.speech.sdk.bundle.js: A human-readable version of the Speech SDK.
  • microsoft.cognitiveservices.speech.sdk.bundle.js.map: A map file that's used for debugging SDK code.
  • microsoft.cognitiveservices.speech.sdk.bundle.d.ts: Object definitions for use with TypeScript.
  • microsoft.cognitiveservices.speech.sdk.bundle-min.js: A minified version of the Speech SDK.
  • speech-processor.js: Code to improve performance on some browsers.

Create an index.html page

Create a new file named index.html in the folder, and open this file with a text editor.

Next steps