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 or 18.04 PC with a working microphone.
-
Required packages to build and run this sample:
sudo apt-get update sudo apt-get install build-essential libssl1.0.0 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/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
toTARGET_PLATFORM:=x86
.
- In the line
- 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 withwestus
if you are using the 30-day free trial subscription.
- Replace the string
- Run the command
make
to 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