Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Quickstart: Recognize speech in C++ for Linux (Ubuntu 16.04, Ubuntu 18.04, Debian 9)

This sample demonstrates how to recognize speech with C++ using the Speech SDK for Linux. See the accompanying article on the SDK documentation page for step-by-step instructions.

Prerequisites

  • A subscription key for the Speech service. See Try the speech service for free.

  • An Ubuntu 16.04, Ubuntu 18.04, or Debian 9 PC with a working microphone.

  • On Ubuntu, install these packages to build and run this sample:

    sudo apt-get update
    sudo apt-get install build-essential libssl1.0.0 libasound2 wget
  • On Debian 9, install these packages to build and run this sample:

    sudo apt-get update
    sudo apt-get install build-essential libssl1.0.2 libasound2 wget

Build the sample

  • Download the sample code to your development PC.
  • Download and extract the Speech SDK
    • By downloading the Microsoft Cognitive Services Speech SDK, you acknowledge its license, see Speech SDK license agreement.

    • Run the following commands after replacing the string /your/path with a directory (absolute path) of your choice:

      export SPEECHSDK_ROOT="/your/path"
      mkdir -p "$SPEECHSDK_ROOT"
      wget -O SpeechSDK-Linux.tar.gz https://aka.ms/csspeech/linuxbinary
      tar --strip 1 -xzf SpeechSDK-Linux.tar.gz -C "$SPEECHSDK_ROOT"
  • Navigate to the directory of this sample
  • Edit the file Makefile:
    • In the line SPEECHSDK_ROOT:=/change/to/point/to/extracted/SpeechSDK change the right-hand side to point to the location of your extract Speech SDK for Linux.
    • If you are running on 32-bit Linux, change the line TARGET_PLATFORM:=x64 to TARGET_PLATFORM:=x86.
  • Edit the helloworld.cpp source:
    • Replace the string YourSubscriptionKey with your own subscription key.
    • Replace the string YourServiceRegion with the service region of your subscription. For example, replace with westus if you are using the 30-day free trial subscription.
  • Run the command make to build the sample, the resulting executable will be called helloworld.

Run the sample

To run the sample, you'll need to configure the loader's library path to point to the Speech SDK library.

  • On an x64 machine, run:

    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SPEECHSDK_ROOT/lib/x64"
  • On an x86 machine, run:

    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SPEECHSDK_ROOT/lib/x86"

Run the application:

./quickstart-linux

References