Command-line Clients
Contents
Command-line Clients¶
Data center
A Docker image containing sample command-line drivers for the Riva services is available on NGC. Pull and run the container by using the following commands. The client expects that a Riva server is running with models deployed, and all command-line drivers accept an optional argument to specify the location of the server. No GPU is required to run the sample clients.
docker pull nvcr.io/nvidia/riva/riva-speech-client:2.1.0
docker run -it --rm nvcr.io/nvidia/riva/riva-speech-client:2.1.0
Embedded
The sample command-line clients are present in the Riva server container. Refer to the Quick Start Guide for steps on how to launch the Riva server container.
Speech Recognition¶
Both binary and Python clients are included in the Docker image with options to perform ASR inference in streaming as well as offline (non-streaming) mode.
Binary Streaming Example¶
Run the ASR streaming client, where --audio_file
specifies the
audio file that is to be transcribed. Other options can be found in
riva_streaming_asr_client --help
.
riva_streaming_asr_client --audio_file /work/wav/test/1272-135031-0001.wav
Binary Offline/Batch (non-streaming) Example¶
Run the binary ASR offline client, where --audio_file
specifies the
audio file that is to be transcribed. Other options can be found in
riva_asr_client --help
.
riva_asr_client --audio_file /work/wav/test/1272-135031-0001.wav
Python Streaming Example¶
Run the Python ASR streaming client, where --input-file
specifies the
audio file that is to be transcribed. Other options can be found in
riva_streaming_asr_client.py
.
python riva_streaming_asr_client.py --input-file=/work/wav/test/1272-135031-0001.wav
The transcribe_mic.py
example is the preferred, cross-platform way
to interact with Riva. Additionally, using a microphone from an arbitrary remote system
running on any operating system and hardware platform is recommended.
python transcribe_mic.py --input-device <device_id>
where the <device_id>
of your audio input device can be obtained from:
python transcribe_mic.py --list-devices
Other Python ASR clients are also available.
transcribe_file.py
transcribes audio files in streaming mode.transcribe_file_offline.py
transcribes audio files in offline mode.transcribe_file_rt.py
transcribes audio files while playing back through PyAudio stream.
Natural Language Processing¶
Both binary and Python clients are included in the Docker image for supported NLP tasks.
Binary NER Example¶
Run the Token Classification Model (NER), where --queries
specifies the
query file in which to provide token labels for. Other options can be found in
riva_nlp_classify_tokens --help
.
riva_nlp_classify_tokens --queries=/work/test_files/nlu/queries.txt
Binary QA Example¶
Run the binary Question Answering client, where --questions
specifies the
file containing questions and --contexts
specifies the file containing the context
paragraph. Other options can be found in riva_nlp_qa --help
.
riva_nlp_qa --questions=/work/test_files/nlu/qa_questions.txt --contexts=/work/test_files/nlu/qa_contexts.txt
Python QA Example¶
Run the Python Question Answering client. Modify test_context
and req.query
in the test_qa.py
script to try different Question Answering examples.
python test_qa.py
Python Intent Slot Example¶
Run the Python Intent Slot Classification client, where --query
specifies the query string.
python intentslot_client.py --query "your query" --model riva_intent_misty --api "intent_slot"
Binary Punctuation Example¶
Run the Punctuation client, where --queries
specifies the file containing
inputs to punctuate. Note that if you want to specify --output
to write output of the
punctuation model to a file, you need to also specify --parallel_requests=1
.
riva_nlp_punct --queries=/work/test_files/nlu/punctuation_input.txt
Speech Synthesis¶
Binary clients are supported in the Docker image for TTS.
Binary TTS Client Example¶
Run the binary TTS client, where --text
is used to specify the input text for which to
synthesize audio. The output of the client is a .wav
file which can be specified by --audio_file
. Other options can be
found in riva_tts_client --help
.
riva_tts_client --text="I had a dream yesterday." --audio_file=/work/wav/output.wav
Binary TTS Performance Client Example¶
Run the binary TTS Performance client which provides information about latency and
throughput. Options --text
specifies the input text and --text_file
specifies the file containing multiple text inputs. Other options can be found in
riva_tts_perf_client --help
.
riva_tts_perf_client --text_file=/work/test_files/tts/ljs_audio_text_test_filelist_small.txt
Python Client Examples¶
Two command-line clients implemented in Python are provided as an example of how to
interact with the TTS service using the Python API. The talk.py
script is an implementation of a client
for performing offline inference, and talk_stream.py
is an implementation using online inference
(with audio being streamed back to the client in chunks).
python talk_stream.py --output-device <device_id>
where the <device_id>
of your audio output device can be obtained from:
python talk_stream.py --list-devices
The talk.py
script can be used with similar arguments as above.