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.
-
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
- 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/pathwith 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/SpeechSDKchange 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:=x64toTARGET_PLATFORM:=x86.
- In the line
- Edit the
helloworld.cppsource:- Replace the string
YourSubscriptionKeywith your own subscription key. - Replace the string
YourServiceRegionwith the service region of your subscription. For example, replace withwestusif you are using the 30-day free trial subscription.
- Replace the string
- Run the command
maketo build the sample, the resulting executable will be calledhelloworld.
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