Package: nvidia-riva-client
NVIDIA Riva ClientsNVIDIA Riva is a GPU-accelerated SDK for building Speech AI applications that are customized for your use
case and deliver real-time performance. This repo provides performant client example command-line clients.Main APIriva.client.ASRServiceis a class for speech recognition,riva.client.TTSServiceis a class for speech synthesis,riva.client.NLPServiceis a class for natural language processing.CLI interfaceAutomatic Speech Recognition (ASR)scripts/asr/riva_streaming_asr_client.pydemonstrates streaming transcription in several threads, can prints time stamps.scripts/asr/transcribe_file.pyperforms streaming transcription,scripts/asr/transcribe_file_offline.pyperforms offline transcription,scripts/asr/transcribe_mic.pyperforms streaming transcription of audio acquired through microphone.Speech Synthesis (TTS)scripts/tts/talk.pysynthesizes audio for a text in streaming or offline mode.Natural Language Processing (NLP)scripts/nlp/intentslot_client.pyrecognizes intents and slots in input sentences,scripts/nlp/ner_client.pydetects named entities in input sentences,scripts/nlp/punctuation_client.pyrestores punctuation and capitalization in input sentences,scripts/nlp/qa_client.pyqueries a document with natural language query and prints answer from a document,scripts/nlp/text_classify_client.pyclassifies input sentences,scripts/nlp/eval_intent_slot.pyprints intents and slots classification reports for test data.InstallationCreate acondaenvironment and activate itFrom source:Cloneriva-python-clientsrepo and change to the repo rootRun commandsgitclonehttps://github.com/nvidia-riva/python-clients.gitcdpython-clients
gitsubmoduleinit
gitsubmoduleupdate--remote--recursive
pipinstall-rrequirements.txt
python3setup.pybdist_wheel
pipinstall--force-reinstalldist/*.whlpip:pipinstallnvidia-riva-clientIf you would like to use output and input audio devices
(scriptsscripts/asr/transcribe_file_rt.py,scripts/asr/transcribe_mic.py,scripts/tts/talk.pyor moduleriva.client/audio_io.py), you will need to installPyAudio.condainstall-canacondapyaudioFor NLP evaluation you will needtransformersandsklearnlibraries.pipinstall-Uscikit-learn
pipinstall-UtransformersBefore using microphone and audio output devices on Unixyou may need to run commandsadduser $USER audio
adduser $USER pulse-accessand restart.UsageServerBefore running client part of Riva, please set up a server. The simplest
way to do this is to followquick start guide.CLIYou may find all CLI scripts inscriptsdirectory. Each script has a description of
its purpose and parameters.ASRYou may find a detailed documentationhere.For transcribing in streaming mode you may usescripts/asr/transcribe_file.py.pythonscripts/asr/transcribe_file.py\--input-filedata/examples/en-US_AntiBERTa_for_word_boosting_testing.wavYou may watch how a transcript grows if you set--simulate-realtimeand--show-intermediate.pythonscripts/asr/transcribe_file.py\--input-filedata/examples/en-US_AntiBERTa_for_word_boosting_testing.wav\--simulate-realtime\--show-intermediateYou may listen audio simultaneously with transcribing (you will need installed PyAudio and access to audio devices).pythonscripts/asr/transcribe_file.py\--input-filedata/examples/en-US_AntiBERTa_for_word_boosting_testing.wav\--play-audio\--show-intermediateOffline transcription is performed this way.pythonscripts/asr/transcribe_file_offline.py\--input-filedata/examples/en-US_AntiBERTa_for_word_boosting_testing.wavYou can improve transcription of this audio by word boosting.pythonscripts/asr/transcribe_file_offline.py\--input-filedata/examples/en-US_AntiBERTa_for_word_boosting_testing.wav\--boosted-lm-wordsAntiBERTa\--boosted-lm-wordsABlooper\--boosted-lm-score20.0NLPYou can provide inputs toscripts/nlp/intentslot_client.py,scripts/nlp/punctuation_client.pyboth through command line arguments and interactively.pythonscripts/nlp/intentslot_client.py--query"What is the weather tomorrow?"orpythonscripts/nlp/intentslot_client.py--interactiveFor punctuation client the commands look similar.pythonscripts/nlp/punctuation_client.py--query"can you prove that you are self aware"orpythonscripts/nlp/punctuation_client.py--interactiveNERclient can output 1 of the following: label name, span start, span endpythonscripts/nlp/ner_client.py\--query"Where is San Francisco?""Jensen Huang is the CEO of NVIDIA Corporation."\--testlabelorpythonscripts/nlp/ner_client.py\--query"Where is San Francisco?""Jensen Huang is the CEO of NVIDIA Corporation."\--testspan_startorpythonscripts/nlp/ner_client.py\--query"Where is San Francisco?""Jensen Huang is the CEO of NVIDIA Corporation."\--testspan_endProvide query and context toQAclient.pythonscripts/nlp/qa_client.py\--query"How many gigatons of carbon dioxide was released in 2005?"\--context"In 2010 the Amazon rainforest experienced another severe drought, in some ways "\"more extreme than the 2005 drought. The affected region was approximate 1,160,000 square "\"miles (3,000,000 km2) of rainforest, compared to 734,000 square miles (1,900,000 km2) in "\"2005. The 2010 drought had three epicenters where vegetation died off, whereas in 2005 the "\"drought was focused on the southwestern part. The findings were published in the journal "\"Science. In a typical year the Amazon absorbs 1.5 gigatons of carbon dioxide; during 2005 "\"instead 5 gigatons were released and in 2010 8 gigatons were released."Text classificationrequires only a query.pythonscripts/nlp/text_classify_client.py--query"How much sun does california get?"TTSCallscripts/tts/talk.pyscript, and you will be prompted to enter a text for speech
synthesis. Set--play-audiooption, and a synthesized speech will be played.pythonscripts/tts/talk.py--play-audioYou can write output to file.pythonscripts/tts/talk.py--output'my_synth_speech.wav'You can use streaming mode (audio fragments returned to client as soon as they are ready).pythonscripts/tts/talk.py--stream--play-audioAPISee tutorial notebooks in directorytutorials.DocumentationAdditional documentation on the Riva Speech Skills SDK can be foundhere.LicenseThis client code is MIT-licensed. See LICENSE file for full details.