Quickstart: Install the Speech SDK

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

In this quickstart, you 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. Windows 10 or later is required.

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 by using the following dotnet add command:

dotnet add package Microsoft.CognitiveServices.Speech

You can follow these guides for more options.

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

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.

  2. Under Get started, select Create a new project.

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

  4. In Configure your new project, for Project name enter helloworld, 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 box.

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

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

    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 dropdown 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, enter 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, select Build > Configuration Manager. The Configuration Manager dialog box appears.

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

    Screenshot that shows the Configuration Manager dialog box.

  3. In the Type or select the new platform dropdown 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

In this quickstart, you install the Speech SDK for C++.

Platform requirements

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

On Windows, you must use the 64-bit target architecture. Windows 10 or later is required.

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 by using the following dotnet add command:

dotnet add package Microsoft.CognitiveServices.Speech

You can follow these guides for more options.

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.

  1. Choose a directory for the Speech SDK files. Set the SPEECHSDK_ROOT environment variable to point to that directory. This variable makes it easy to refer to the directory in future commands.

    To use the directory speechsdk in your home directory, run the following command:

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

    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 partner notices 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 Partner 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

In this quickstart, you install the Speech SDK for Go.

Platform requirements

The Speech SDK for Go supports the following distributions on the x64 architecture:

  • Ubuntu 20.04/22.04/24.04
  • Debian 11/12

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, version 1.x (libssl1) or 3.x (libssl3), and certificates (ca-certificates).
  • The shared library for ALSA applications (libasound2).

Run these commands:

sudo apt-get update
sudo apt-get install build-essential ca-certificates libasound2-dev libssl-dev wget

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.

  1. Choose a directory for the Speech SDK files. Set the SPEECHSDK_ROOT environment variable to point to that directory. This variable makes it easy to refer to the directory in future commands.

    To use the directory speechsdk in your home directory, run the following command:

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

    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 partner notices 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 Partner 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.

  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"
    

    Important

    Replace <architecture> with the processor architecture of your CPU: x64, arm32, or arm64.

  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"
    

    Important

    Replace <architecture> with the processor architecture of your CPU: x64, arm32, or arm64.

Reference documentation | Additional samples on GitHub

In this quickstart, you 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 64-bit target architecture. Windows 10 or later is required.

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.

The Speech SDK for Java doesn't support Windows on ARM64.

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. To check the latest version, search our GitHub repository.

Choose your target environment:

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

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>
        <dependencies>
            <dependency>
            <groupId>com.microsoft.cognitiveservices.speech</groupId>
            <artifactId>client-sdk</artifactId>
            <version>1.40.0</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

In this quickstart, you 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

Understand the architectural implications between Node.js and client web browsers. For example, the document object model (DOM) isn't available for server-side applications. 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:

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");

Reference documentation | Package (download) | Additional samples on GitHub

In this quickstart, you install the Speech SDK for Objective-C.

Tip

For more information 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 systems.

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 content. 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.40.0'
    end
    
  4. Run pod install to install the Speech SDK.

Alternatively, download the binary CocoaPod and 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

In this quickstart, you install the Speech SDK for Swift.

Tip

For more information 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 systems.

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 content. 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.40.0'
    end
    
  4. Run pod install to install the Speech SDK.

Alternatively, download the binary CocoaPod and 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

In this quickstart, you install the Speech SDK for Python.

Platform requirements

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

On Windows, you must use the 64-bit target architecture. Windows 10 or later is required.

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, install the x64 Python package.

Install a version of Python from 3.8 or later.

  • To check your installation, open a terminal and run the command python --version. If Python installed properly, you 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.

Install from PyPI

To install the Speech SDK for Python, run this command in a console window:

pip install azure-cognitiveservices-speech

Upgrade to the latest Speech SDK

To upgrade to the latest Speech SDK, run this command in console window:

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 console window:

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