Azure Speech CLI
Unofficial CLI tool for Microsoft Azure Speech Service management - datasets, models, tests, endpoints etc. Useful especially for automation.
Until this is refactored, it's not safe to regenerate the SDK with AutoRest.
Go to Releases to download a compiled version for your operating system, or build directly from sources.
CLI is created with .NET Core and builds are currently running for both Windows and MacOS platforms.
Windows Store version is planned.
Before using the tool, you need to set your Speech Service credentials.
speech config set --name Project1 --key ABCD12345 --region northeurope --select
Or shorter version:
speech config set -n Project2 -k ABCD54321 -r westus -s
Both commands store your credentials as configuration set and automatically make these credentials selected (by using the
--select parameter). You can have multiple sets and switch between them:
speech config select --name Project1
This can be useful when you work with multiple subscriptions.
If you're not sure what commands and parameters are available, try adding
--help to the command you want to use.
speech --help speech dataset --help speech dataset create --help
Every entity supports basic set of operations:
When working with a specific entity, ID is usually required:
speech dataset show --id <GUID>
Every create command offers optional
--wait flag which makes the CLI block and wait for the create operation to complete (dataset processed, model trained, endpoint provisioned etc.). When new entity is created, it writes corresponding ID to console.
This is useful in automation pipelines when commands are run as individual steps in a complex process.
speech dataset create --name CLI --audio "C:\Test.zip" --transcript "C:\test.txt" --wait Uploading acoustic dataset... Processing [..............] c34d53e4-oooo-48d5-b18f-7492332f287c
After setting your subscription key and endpoint you usually start by preparing data. CLI can help by providing the
speech compile --audio <source folder> --transcript <txt file> --output <target folder> --test-percentage 10
This command expects a folder with all audio samples as WAV files and TXT file with corresponding transcripts.
It creates the output folder, divides data in two sets ("train" and "test") a compresses them into ZIP files. At the end you will get:
There are two types of datasets in the Speech Service: acoustic and language.
To create the acoustic dataset, you need to provide a ZIP file with all audio samples and TXT file with corresponding transcriptions.
To create the language dataset, you need to provide TXT file with language data.
To create an acoustic dataset use:
dataset create --name CLI --audio "C:\Train.zip" --transcript "C:\train.txt" --wait
To create a language dataset use:
dataset create --name CLI-Lang --language "C:\language.txt" --wait
To list available datasets:
To show details of dataset:
dataset show --id 63f20d88-f531-4af0-bc85-58e0e9dAAACCDD
Similarly to datasets there are two types of models in the Speech Service: acoustic and language. Both are created from previously uploaded datasets.
To create an acoustic model you first need to get GUID of base model (referred to as scenario):
model list-scenarios --locale en-us
en-us is the default locale, but you can choose a different one.
Getting scenarios... d36f6c4b-8f75-41d1-b126-c38e46a059af Unified V3 EMBR - ULM c7a69da3-27de-4a4b-ab75-b6716f6321e5 V2.5 Conversational (AM/LM adapt) a1f8db59-40ff-4f0e-b011-37629c3a1a53 V2.0 Conversational (AM/LM adapt) - Deprecated cc7826ac-5355-471d-9bc6-a54673d06e45 V1.0 Conversational (AM/LM adapt) - Deprecated a3d8aab9-6f36-44cd-9904-b37389ce2bfa V1.0 Interactive (AM/LM adapt) - Deprecated
Then you can use GUID of selected scenario in the
model create --name CLI --locale en-us --audio-dataset <GUID> --scenario c7a69da3-27de-4a4b-ab75-b6716f6321e5 --wait
To create a language model you need the same scenario GUID and then call:
model create --name CLI-Lang --locale en-us --language-dataset <GUID> --scenario c7a69da3-27de-4a4b-ab75-b6716f6321e5 --wait
To create an accuracy test you need three GUIDs: testing audio dataset ID, ID of the acoustic model you are testing and ID of a language model:
speech test create --name CLI --audio-dataset <GUID> --model <GUID> --language-model <GUID> --wait
To see the detail of particular test, call:
speech test list ... speech test show --id <GUID>
And finally, to be able to use the model, you need to create an endpoint.
To create an endpoint use:
speech endpoint create --name CLI --locale en-us --model <GUID> --language-model <GUID> --concurrent-recognitions 1 --wait
A bonus command, which doesn't revolve around entities. Batch transcription generates a transcript of long audio file with timestamps, using your custom model.
speech transcript create --name CLI --locale en-us --recording <URL> --model <GUID> --language <GUID> --wait
Once the batch is done, you can call:
speech transcript show --id <GUID>
And get result URLs from response JSON.
Or you can call:
speech transcript download --id <GUID> --out-dir <PATH> --format VTT
To download transcriptions and convert them to VTT (default is
- Work with names too, not just GUIDs
- Rework how configuration is initialized and checked on startup
- Check if uploaded files are in the correct format (UTF-8 BOM text files)
- Publish to Windows Store too
- Add unit tests :)
By participating in this project, you agree to abide by the Microsoft Open Source Code of Conduct.