Install the Speech SDK

Reference documentation | Package (NuGet) | Additional Samples on GitHub

This guide shows how to install the Speech SDK for C#.

Code samples in the documentation are written in C# 8 and run on .NET standard 2.0.

Platform requirements

The Speech SDK for C# is compatible with Windows, Linux, and macOS.

On Windows, you must use the 64-bit target architecture.

You must install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022 for your platform. Installing this package for the first time might require a restart.

Install the Speech SDK for C#

The Speech SDK for C# is available as a NuGet package and implements .NET Standard 2.0. For more information, see Microsoft.CognitiveServices.Speech.

The Speech SDK for C# can be installed from the .NET CLI with the following dotnet add command:

dotnet add package Microsoft.CognitiveServices.Speech

The Speech SDK for C# can be installed with the following Install-Package command:

Install-Package Microsoft.CognitiveServices.Speech

You can follow a guide below for additional options.

Choose your target environment

This guide shows how to install the Speech SDK for a .NET Framework (Windows) console app.

Prerequisites

This guide 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.

Reference documentation | Package (NuGet) | Additional Samples on GitHub

This guide shows how to install the Speech SDK for C++.

Platform requirements

The Speech SDK for C++ is compatible with Windows, Linux, and macOS.

On Windows, you can use the x64 or x86 target architecture.

You must install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022 for your platform. Installing this package for the first time might require a restart.

Install the Speech SDK for C++

The Speech SDK for C++ is available as a NuGet package. For more information, see Microsoft.CognitiveServices.Speech.

The Speech SDK for C++ can be installed from the .NET CLI with the following dotnet add command:

dotnet add package Microsoft.CognitiveServices.Speech

The Speech SDK for C# can be installed with the following Install-Package command:

Install-Package Microsoft.CognitiveServices.Speech

You can follow a guide below for additional options.

Choose your target environment

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

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

Reference documentation | Package (Go) | Additional Samples on GitHub

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

Platform requirements

The Speech SDK for Go only supports Ubuntu 18.04/20.04/22.04, Debian 9/10/11, Red Hat Enterprise Linux (RHEL) 8, and CentOS 8 on the x64 architecture when used with Linux.

Important

Use the most recent LTS release of the Linux distribution. For example, if you are using Ubuntu 20.04 LTS, use the latest release of Ubuntu 20.04.X.

The Speech SDK depends on the following Linux system libraries:

  • The shared libraries of the GNU C library, including the POSIX Threads Programming library, libpthreads
  • The OpenSSL library (libssl) version 1.x
  • The shared library for ALSA applications (libasound)
sudo apt-get update
sudo apt-get install build-essential libssl-dev libasound2 wget

Important

On Ubuntu 22.04, install libssl1.1 either as a binary package such as libssl1.1_1.1.1l-1ubuntu1.3_amd64.deb, or by compiling it from sources. The Speech SDK does not support OpenSSL 3.0, which is the default in Ubuntu 22.04.

Here's an example of installing libssl1.1 on Ubuntu 22.04:

wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1l-1ubuntu1.3_amd64.deb
sudo dpkg -i libssl1.1_1.1.1l-1ubuntu1.3_amd64.deb

You must install the Go binary version 1.13 or later.

Install the Speech SDK for Go

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"
    

Reference documentation | Additional Samples on GitHub

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

Platform requirements

Choose your target environment

The Speech SDK for Java is compatible with Windows, Linux, and macOS.

On Windows, you must use the x64 target architecture.

You must install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022 for your platform. Installing this package for the first time might require a restart.

You must install a Java Development Kit such as Azul Zulu OpenJDK. The Microsoft Build of OpenJDK or your preferred JDK should also work.

Install the Speech SDK for Java

Some of the instructions use a specific SDK version such as 1.24.2. You can check the latest version by searching our GitHub repo.

Choose your target environment

This guide shows how to install the Speech SDK for Java on the Java Runtime.

Note

The Speech SDK for Java 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.)

Supported operating systems

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

Follow these steps to install the Speech SDK for Java using Apache Maven:

  1. Install Apache Maven.
  2. Open a command prompt where you want the new project, and create a new pom.xml file.
  3. Copy the following XML content into pom.xml:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.microsoft.cognitiveservices.speech.samples</groupId>
        <artifactId>quickstart-eclipse</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <build>
            <sourceDirectory>src</sourceDirectory>
            <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                <source>1.8</source>
                <target>1.8</target>
                </configuration>
            </plugin>
            </plugins>
        </build>
        <repositories>
            <repository>
            <id>maven-cognitiveservices-speech</id>
            <name>Microsoft Cognitive Services Speech Maven Repository</name>
            <url>https://azureai.azureedge.net/maven/</url>
            </repository>
        </repositories>
        <dependencies>
            <dependency>
            <groupId>com.microsoft.cognitiveservices.speech</groupId>
            <artifactId>client-sdk</artifactId>
            <version>1.24.2</version>
            </dependency>
        </dependencies>
    </project>
    
  4. Run the following Maven command to install the Speech SDK and dependencies.
    mvn clean dependency:copy-dependencies
    

Reference documentation | Package (npm) | Additional Samples on GitHub | Library source code

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

The Speech SDK for JavaScript is available as an npm package. See microsoft-cognitiveservices-speech-sdk and its companion GitHub repository cognitive-services-speech-sdk-js.

Platform requirements

Make sure to consider the various architectural implications between Node.js and client web browsers. For example, the document object model (DOM) isn't available for server-side applications just as the Node.js file system isn't available to client-side applications.

Install the Speech SDK for JavaScript

Depending on the target environment, use one of the following guides:

Choose your target environment

This guide shows how to install the Speech SDK for JavaScript for use with Node.js. If you just want the package name to get started on your own, run npm install microsoft-cognitiveservices-speech-sdk from your existing project.

Prerequisites

This quickstart requires Node.js.

Create an npm project

Create a new directory, run npm init, and walk through the prompts.

Add the Speech SDK package

Run npm install microsoft-cognitiveservices-speech-sdk.

This guide shows how to install the Speech SDK for JavaScript for use with Node.js.

  1. Install Node.js.

  2. Create a new directory, run npm init, and walk through the prompts.

  3. To install the Speech SDK for JavaScript, run the following npm install command:

    npm install microsoft-cognitiveservices-speech-sdk
    

For more information, see the Node.js samples.

Use the Speech SDK

Add the following import statement to use the Speech SDK in your JavaScript project:

import * as sdk from "microsoft-cognitiveservices-speech-sdk";

For more information on import, see Export and Import on the JavaScript website.

Alternatively, you could use a require statement:

const sdk = require("microsoft-cognitiveservices-speech-sdk");

For more information on require, see What is require? on the Node.js website.

Reference documentation | Package (Download) | Additional Samples on GitHub

This guide shows how to install the Speech SDK for Objective-C.

Tip

For details about using the Speech SDK for Swift, see Importing Objective-C into Swift.

Install the Speech SDK for Objective-C

The Speech SDK for Objective-C is available natively as a CocoaPod package for Mac x64 and ARM-based silicons.

System requirements for Mac:

  • A macOS version 10.14 or later

The macOS CocoaPod package is available for download and use with the Xcode 9.4.1 (or later) integrated development environment (IDE).

  1. Go to the Xcode directory where your .xcodeproj project file is located.

  2. Run pod init to create a pod file named Podfile.

  3. Replace the contents of Podfile with the following. Update the target name from 'AppName' to the name of your app. Update the platform or pod version as needed.

    platform :osx, 10.14
    use_frameworks!
    
    target 'AppName' do
      pod 'MicrosoftCognitiveServicesSpeech-macOS', '~> 1.24.0'
    end
    
  4. Run pod install to install the Speech SDK.

Alternatively, you can download the binary CocoaPod and unzip to extract its contents. In your Xcode project, add a reference to the extracted "MicrosoftCognitiveServicesSpeech.xcframework" folder and its contents.

Note

.NET developers can build native macOS applications by using the Xamarin.Mac application framework. For more information, see Xamarin.Mac.

Reference documentation | Package (Download) | Additional Samples on GitHub

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

Tip

For details about using the Speech SDK for Swift, see Importing Objective-C into Swift.

Install the Speech SDK for Swift

The Speech SDK for Swift is available natively as a CocoaPod package for Mac x64 and ARM-based silicons.

System requirements for Mac:

  • A macOS version 10.14 or later

The macOS CocoaPod package is available for download and use with the Xcode 9.4.1 (or later) integrated development environment (IDE).

  1. Go to the Xcode directory where your .xcodeproj project file is located.

  2. Run pod init to create a pod file named Podfile.

  3. Replace the contents of Podfile with the following. Update the target name from 'AppName' to the name of your app. Update the platform or pod version as needed.

    platform :osx, 10.14
    use_frameworks!
    
    target 'AppName' do
      pod 'MicrosoftCognitiveServicesSpeech-macOS', '~> 1.24.0'
    end
    
  4. Run pod install to install the Speech SDK.

Alternatively, you can download the binary CocoaPod and unzip to extract its contents. In your Xcode project, add a reference to the extracted "MicrosoftCognitiveServicesSpeech.xcframework" folder and its contents.

Note

.NET developers can build native macOS applications by using the Xamarin.Mac application framework. For more information, see Xamarin.Mac.

Reference documentation | Package (PyPi) | Additional Samples on GitHub

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

Platform requirements

The Speech SDK for Python is compatible with Windows, Linux, and macOS.

On Windows, you can use the x64 or x86 target architecture.

You must install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022 for your platform. Installing this package for the first time might require a restart.

Important

Make sure that packages of the same target architecture are installed. For example, if you install the x64 redistributable package, then you need to install the x64 Python package.

Install a version of Python from 3.7 to 3.10.

To check your installation, open a terminal and run the command python --version. If it's installed properly, you'll get a response like "Python 3.8.10". If you're using macOS or Linux, you might need to run the command python3 --version instead. To enable use of python instead of python3, run alias python='python3' to set up an alias. The Speech SDK quickstart samples specify python usage.

Install the Speech SDK for Python

Before you install the Speech SDK for Python, make sure to satisfy the platform requirements.

Choose your tool or IDE

Install from PyPI

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

pip install azure-cognitiveservices-speech

Upgrade to the latest Speech SDK

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

pip install --upgrade azure-cognitiveservices-speech

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

pip list

Use the Speech SDK

Add the following import statement to use the Speech SDK in your Python project:

import azure.cognitiveservices.speech as speechsdk

Next steps