nvidia-riva-client 2.22.0__2-py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nvidia_riva_client-2.22.0.dist-info/METADATA +413 -0
- nvidia_riva_client-2.22.0.dist-info/RECORD +31 -0
- nvidia_riva_client-2.22.0.dist-info/WHEEL +5 -0
- nvidia_riva_client-2.22.0.dist-info/licenses/LICENSE +19 -0
- nvidia_riva_client-2.22.0.dist-info/top_level.txt +1 -0
- riva/client/__init__.py +43 -0
- riva/client/argparse_utils.py +135 -0
- riva/client/asr.py +485 -0
- riva/client/audio_io.py +143 -0
- riva/client/auth.py +142 -0
- riva/client/health.py +0 -0
- riva/client/nlp.py +402 -0
- riva/client/nmt.py +184 -0
- riva/client/package_info.py +26 -0
- riva/client/proto/__init__.py +0 -0
- riva/client/proto/health_pb2.py +43 -0
- riva/client/proto/health_pb2_grpc.py +140 -0
- riva/client/proto/riva_asr_pb2.py +81 -0
- riva/client/proto/riva_asr_pb2_grpc.py +202 -0
- riva/client/proto/riva_audio_pb2.py +37 -0
- riva/client/proto/riva_audio_pb2_grpc.py +24 -0
- riva/client/proto/riva_common_pb2.py +37 -0
- riva/client/proto/riva_common_pb2_grpc.py +24 -0
- riva/client/proto/riva_nlp_pb2.py +190 -0
- riva/client/proto/riva_nlp_pb2_grpc.py +439 -0
- riva/client/proto/riva_nmt_pb2.py +73 -0
- riva/client/proto/riva_nmt_pb2_grpc.py +242 -0
- riva/client/proto/riva_tts_pb2.py +57 -0
- riva/client/proto/riva_tts_pb2_grpc.py +191 -0
- riva/client/realtime.py +489 -0
- riva/client/tts.py +152 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nvidia-riva-client
|
|
3
|
+
Version: 2.22.0
|
|
4
|
+
Summary: Python implementation of the Riva Client API
|
|
5
|
+
Home-page: https://github.com/nvidia-riva/python-clients
|
|
6
|
+
Author: Anton Peganov
|
|
7
|
+
Author-email: apeganov@nvidia.com
|
|
8
|
+
Maintainer: Anton Peganov
|
|
9
|
+
Maintainer-email: apeganov@nvidia.com
|
|
10
|
+
License: MIT
|
|
11
|
+
Keywords: deep learning,machine learning,gpu,NLP,ASR,TTS,NMT,nvidia,speech,language,Riva,client
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Requires-Python: >=3.7
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: setuptools==78.1.1
|
|
19
|
+
Requires-Dist: grpcio==1.67.1
|
|
20
|
+
Requires-Dist: grpcio-tools==1.67.1
|
|
21
|
+
Requires-Dist: websockets==15.0.1
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: keywords
|
|
29
|
+
Dynamic: license
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
Dynamic: maintainer
|
|
32
|
+
Dynamic: maintainer-email
|
|
33
|
+
Dynamic: requires-dist
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
|
36
|
+
|
|
37
|
+
[](https://opensource.org/licenses/MIT)
|
|
38
|
+
# NVIDIA Riva Clients
|
|
39
|
+
|
|
40
|
+
NVIDIA Riva is a GPU-accelerated SDK for building Speech AI applications that are customized for your use
|
|
41
|
+
case and deliver real-time performance. This repo provides performant client example command-line clients.
|
|
42
|
+
|
|
43
|
+
## Main API
|
|
44
|
+
|
|
45
|
+
- `riva.client.ASRService` is a class for speech recognition,
|
|
46
|
+
- `riva.client.TTSService` is a class for speech synthesis,
|
|
47
|
+
- `riva.client.NLPService` is a class for natural language processing.
|
|
48
|
+
|
|
49
|
+
## CLI interface
|
|
50
|
+
|
|
51
|
+
- **Automatic Speech Recognition (ASR)**
|
|
52
|
+
- `scripts/asr/riva_streaming_asr_client.py` demonstrates streaming transcription in several threads, can prints time stamps.
|
|
53
|
+
- `scripts/asr/transcribe_file.py` performs streaming transcription,
|
|
54
|
+
- `scripts/asr/transcribe_file_offline.py` performs offline transcription,
|
|
55
|
+
- `scripts/asr/transcribe_mic.py` performs streaming transcription of audio acquired through microphone.
|
|
56
|
+
- `scripts/asr/realtime_asr_client.py` performs realtime transcription of audio via WebSocket connection.
|
|
57
|
+
- **Speech Synthesis (TTS)**
|
|
58
|
+
- `scripts/tts/talk.py` synthesizes audio for a text in streaming or offline mode.
|
|
59
|
+
- **Natural Language Processing (NLP)**
|
|
60
|
+
- `scripts/nlp/intentslot_client.py` recognizes intents and slots in input sentences,
|
|
61
|
+
- `scripts/nlp/ner_client.py` detects named entities in input sentences,
|
|
62
|
+
- `scripts/nlp/punctuation_client.py` restores punctuation and capitalization in input sentences,
|
|
63
|
+
- `scripts/nlp/qa_client.py` queries a document with natural language query and prints answer from a document,
|
|
64
|
+
- `scripts/nlp/text_classify_client.py` classifies input sentences,
|
|
65
|
+
- `scripts/nlp/eval_intent_slot.py` prints intents and slots classification reports for test data.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
1. Create a ``conda`` environment and activate it
|
|
70
|
+
2. From source:
|
|
71
|
+
- Clone ``riva-python-clients`` repo and change to the repo root
|
|
72
|
+
- Run commands
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/nvidia-riva/python-clients.git
|
|
76
|
+
cd python-clients
|
|
77
|
+
git submodule init
|
|
78
|
+
git submodule update --remote --recursive
|
|
79
|
+
pip install -r requirements.txt
|
|
80
|
+
python3 setup.py bdist_wheel
|
|
81
|
+
pip install --force-reinstall dist/*.whl
|
|
82
|
+
```
|
|
83
|
+
3. `pip`:
|
|
84
|
+
```bash
|
|
85
|
+
pip install nvidia-riva-client
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
If you would like to use output and input audio devices
|
|
89
|
+
(scripts `scripts/asr/transcribe_file_rt.py`, `scripts/asr/transcribe_mic.py`, `scripts/tts/talk.py`, `scripts/asr/realtime_asr_client.py` or module
|
|
90
|
+
`riva.client/audio_io.py`), you will need to install `PyAudio`.
|
|
91
|
+
```bash
|
|
92
|
+
conda install -c anaconda pyaudio
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
If you would like to use Realtime ASR (WebSocket-based real-time transcription) script `scripts/asr/realtime_asr_client.py`, you will need the following dependencies:
|
|
96
|
+
```bash
|
|
97
|
+
conda install -c anaconda numpy
|
|
98
|
+
conda install -c anaconda requests
|
|
99
|
+
conda install -c anaconda websockets
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For NLP evaluation you will need `transformers` and `sklearn` libraries.
|
|
103
|
+
```bash
|
|
104
|
+
pip install -U scikit-learn
|
|
105
|
+
pip install -U transformers
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Before using microphone and audio output devices on Unix
|
|
109
|
+
you may need to run commands
|
|
110
|
+
```
|
|
111
|
+
adduser $USER audio
|
|
112
|
+
adduser $USER pulse-access
|
|
113
|
+
```
|
|
114
|
+
and restart.
|
|
115
|
+
|
|
116
|
+
## Usage
|
|
117
|
+
|
|
118
|
+
### Server
|
|
119
|
+
|
|
120
|
+
Before running client part of Riva, please set up a server. The simplest
|
|
121
|
+
way to do this is to follow
|
|
122
|
+
[quick start guide](https://docs.nvidia.com/deeplearning/riva/user-guide/docs/quick-start-guide.html#local-deployment-using-quick-start-scripts).
|
|
123
|
+
|
|
124
|
+
### CLI
|
|
125
|
+
|
|
126
|
+
You may find all CLI scripts in `scripts` directory. Each script has a description of
|
|
127
|
+
its purpose and parameters.
|
|
128
|
+
|
|
129
|
+
#### ASR
|
|
130
|
+
|
|
131
|
+
You may find a detailed documentation [here](https://docs.nvidia.com/deeplearning/riva/user-guide/docs/apis/cli.html).
|
|
132
|
+
|
|
133
|
+
For transcribing in streaming mode you may use `scripts/asr/transcribe_file.py`.
|
|
134
|
+
```bash
|
|
135
|
+
python scripts/asr/transcribe_file.py \
|
|
136
|
+
--input-file data/examples/en-US_AntiBERTa_for_word_boosting_testing.wav
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
You may watch how a transcript grows if you set `--simulate-realtime` and `--show-intermediate`.
|
|
140
|
+
```bash
|
|
141
|
+
python scripts/asr/transcribe_file.py \
|
|
142
|
+
--input-file data/examples/en-US_AntiBERTa_for_word_boosting_testing.wav \
|
|
143
|
+
--simulate-realtime \
|
|
144
|
+
--show-intermediate
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
You may listen audio simultaneously with transcribing (you will need installed PyAudio and access to audio devices).
|
|
148
|
+
```bash
|
|
149
|
+
python scripts/asr/transcribe_file.py \
|
|
150
|
+
--input-file data/examples/en-US_AntiBERTa_for_word_boosting_testing.wav \
|
|
151
|
+
--play-audio \
|
|
152
|
+
--show-intermediate
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Offline transcription is performed this way.
|
|
156
|
+
```bash
|
|
157
|
+
python scripts/asr/transcribe_file_offline.py \
|
|
158
|
+
--input-file data/examples/en-US_AntiBERTa_for_word_boosting_testing.wav
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
You can improve transcription of this audio by word boosting.
|
|
162
|
+
```bash
|
|
163
|
+
python scripts/asr/transcribe_file_offline.py \
|
|
164
|
+
--input-file data/examples/en-US_AntiBERTa_for_word_boosting_testing.wav \
|
|
165
|
+
--boosted-lm-words AntiBERTa \
|
|
166
|
+
--boosted-lm-words ABlooper \
|
|
167
|
+
--boosted-lm-score 20.0
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
For transcribing in realtime mode you may use `scripts/asr/realtime_asr_client.py`.
|
|
171
|
+
|
|
172
|
+
**From audio file:**
|
|
173
|
+
```bash
|
|
174
|
+
python scripts/asr/realtime_asr_client.py \
|
|
175
|
+
--input-file data/examples/en-US_AntiBERTa_for_word_boosting_testing.wav
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**From microphone:**
|
|
179
|
+
```bash
|
|
180
|
+
python scripts/asr/realtime_asr_client.py \
|
|
181
|
+
--mic \
|
|
182
|
+
--duration 30 \
|
|
183
|
+
--output-text transcript.txt
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**List available audio devices:**
|
|
187
|
+
```bash
|
|
188
|
+
python scripts/asr/realtime_asr_client.py --list-devices
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Use specific audio device:**
|
|
192
|
+
```bash
|
|
193
|
+
python scripts/asr/realtime_asr_client.py \
|
|
194
|
+
--mic \
|
|
195
|
+
--input-device 1 \
|
|
196
|
+
--duration 30 \
|
|
197
|
+
--output-text transcript.txt
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
For **WebSocket-based Realtime Transcription** (using `riva.client.realtime.RealtimeClient`), you can transcribe audio files or microphone input with real-time results:
|
|
201
|
+
|
|
202
|
+
**From audio file:**
|
|
203
|
+
```python
|
|
204
|
+
from riva.client.realtime import RealtimeClient
|
|
205
|
+
from riva.client.asr import AudioChunkFileIterator
|
|
206
|
+
import asyncio
|
|
207
|
+
import argparse
|
|
208
|
+
|
|
209
|
+
async def transcribe_file():
|
|
210
|
+
# Create arguments namespace
|
|
211
|
+
args = argparse.Namespace()
|
|
212
|
+
args.input_file = "path/to/audio.wav" # Required for file input
|
|
213
|
+
args.mic = False # Set to True for microphone input
|
|
214
|
+
args.server = "localhost:9090"
|
|
215
|
+
args.endpoint = "/v1/realtime"
|
|
216
|
+
args.query_params = "intent=transcription"
|
|
217
|
+
args.sample_rate_hz = 16000
|
|
218
|
+
args.num_channels = 1
|
|
219
|
+
args.file_streaming_chunk = 1600
|
|
220
|
+
args.output_text = "transcript.txt"
|
|
221
|
+
args.prompt = ""
|
|
222
|
+
args.language_code = "en-US"
|
|
223
|
+
args.model_name = ""
|
|
224
|
+
args.automatic_punctuation = False
|
|
225
|
+
args.no_verbatim_transcripts = False
|
|
226
|
+
args.profanity_filter = False
|
|
227
|
+
args.word_time_offsets = False
|
|
228
|
+
args.max_alternatives = 1
|
|
229
|
+
args.boosted_lm_words = []
|
|
230
|
+
args.boosted_lm_score = 4.0
|
|
231
|
+
args.speaker_diarization = False
|
|
232
|
+
args.diarization_max_speakers = 3
|
|
233
|
+
args.start_history = -1
|
|
234
|
+
args.start_threshold = -1.0
|
|
235
|
+
args.stop_history = -1
|
|
236
|
+
args.stop_threshold = -1.0
|
|
237
|
+
args.stop_history_eou = -1
|
|
238
|
+
args.stop_threshold_eou = -1.0
|
|
239
|
+
args.custom_configuration = ""
|
|
240
|
+
|
|
241
|
+
client = RealtimeClient(args=args)
|
|
242
|
+
|
|
243
|
+
await client.connect()
|
|
244
|
+
|
|
245
|
+
# Create audio iterator
|
|
246
|
+
audio_chunk_iterator = AudioChunkFileIterator(
|
|
247
|
+
args.input_file,
|
|
248
|
+
args.file_streaming_chunk,
|
|
249
|
+
delay_callback=None
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
# Send audio and receive responses concurrently
|
|
253
|
+
await asyncio.gather(
|
|
254
|
+
client.send_audio_chunks(audio_chunk_iterator),
|
|
255
|
+
client.receive_responses()
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
client.save_responses("transcript.txt")
|
|
259
|
+
await client.disconnect()
|
|
260
|
+
|
|
261
|
+
asyncio.run(transcribe_file())
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**From microphone:**
|
|
265
|
+
```python
|
|
266
|
+
from riva.client.realtime import RealtimeClient
|
|
267
|
+
from riva.client.audio_io import MicrophoneStream
|
|
268
|
+
import asyncio
|
|
269
|
+
import argparse
|
|
270
|
+
|
|
271
|
+
async def transcribe_microphone():
|
|
272
|
+
# Create arguments namespace
|
|
273
|
+
args = argparse.Namespace()
|
|
274
|
+
args.input_file = None # Not needed for microphone input
|
|
275
|
+
args.mic = True
|
|
276
|
+
args.duration = 30 # 30 seconds
|
|
277
|
+
args.input_device = None # Use default device
|
|
278
|
+
args.server = "localhost:9090"
|
|
279
|
+
args.endpoint = "/v1/realtime"
|
|
280
|
+
args.query_params = "intent=transcription"
|
|
281
|
+
args.sample_rate_hz = 16000
|
|
282
|
+
args.num_channels = 1
|
|
283
|
+
args.file_streaming_chunk = 1600
|
|
284
|
+
args.output_text = "transcript.txt"
|
|
285
|
+
args.prompt = ""
|
|
286
|
+
args.language_code = "en-US"
|
|
287
|
+
args.model_name = ""
|
|
288
|
+
args.automatic_punctuation = False
|
|
289
|
+
args.no_verbatim_transcripts = False
|
|
290
|
+
args.profanity_filter = False
|
|
291
|
+
args.word_time_offsets = False
|
|
292
|
+
args.max_alternatives = 1
|
|
293
|
+
args.boosted_lm_words = []
|
|
294
|
+
args.boosted_lm_score = 4.0
|
|
295
|
+
args.speaker_diarization = False
|
|
296
|
+
args.diarization_max_speakers = 3
|
|
297
|
+
args.start_history = -1
|
|
298
|
+
args.start_threshold = -1.0
|
|
299
|
+
args.stop_history = -1
|
|
300
|
+
args.stop_threshold = -1.0
|
|
301
|
+
args.stop_history_eou = -1
|
|
302
|
+
args.stop_threshold_eou = -1.0
|
|
303
|
+
args.custom_configuration = ""
|
|
304
|
+
|
|
305
|
+
client = RealtimeClient(args=args)
|
|
306
|
+
|
|
307
|
+
await client.connect()
|
|
308
|
+
|
|
309
|
+
# Create microphone stream
|
|
310
|
+
mic_chunks = MicrophoneStream(
|
|
311
|
+
args.sample_rate_hz,
|
|
312
|
+
args.file_streaming_chunk,
|
|
313
|
+
device=None
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
await asyncio.gather(
|
|
317
|
+
client.send_audio_chunks(mic_chunks),
|
|
318
|
+
client.receive_responses()
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
await client.disconnect()
|
|
322
|
+
|
|
323
|
+
asyncio.run(transcribe_microphone())
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
#### NLP
|
|
327
|
+
|
|
328
|
+
You can provide inputs to `scripts/nlp/intentslot_client.py`, `scripts/nlp/punctuation_client.py`
|
|
329
|
+
both through command line arguments and interactively.
|
|
330
|
+
```bash
|
|
331
|
+
python scripts/nlp/intentslot_client.py --query "What is the weather tomorrow?"
|
|
332
|
+
```
|
|
333
|
+
or
|
|
334
|
+
```bash
|
|
335
|
+
python scripts/nlp/intentslot_client.py --interactive
|
|
336
|
+
```
|
|
337
|
+
For punctuation client the commands look similar.
|
|
338
|
+
```bash
|
|
339
|
+
python scripts/nlp/punctuation_client.py --query "can you prove that you are self aware"
|
|
340
|
+
```
|
|
341
|
+
or
|
|
342
|
+
```bash
|
|
343
|
+
python scripts/nlp/punctuation_client.py --interactive
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**NER** client can output 1 of the following: label name, span start, span end
|
|
347
|
+
```bash
|
|
348
|
+
python scripts/nlp/ner_client.py \
|
|
349
|
+
--query "Where is San Francisco?" "Jensen Huang is the CEO of NVIDIA Corporation." \
|
|
350
|
+
--test label
|
|
351
|
+
```
|
|
352
|
+
or
|
|
353
|
+
```bash
|
|
354
|
+
python scripts/nlp/ner_client.py \
|
|
355
|
+
--query "Where is San Francisco?" "Jensen Huang is the CEO of NVIDIA Corporation." \
|
|
356
|
+
--test span_start
|
|
357
|
+
```
|
|
358
|
+
or
|
|
359
|
+
```bash
|
|
360
|
+
python scripts/nlp/ner_client.py \
|
|
361
|
+
--query "Where is San Francisco?" "Jensen Huang is the CEO of NVIDIA Corporation." \
|
|
362
|
+
--test span_end
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Provide query and context to **QA** client.
|
|
366
|
+
```bash
|
|
367
|
+
python scripts/nlp/qa_client.py \
|
|
368
|
+
--query "How many gigatons of carbon dioxide was released in 2005?" \
|
|
369
|
+
--context "In 2010 the Amazon rainforest experienced another severe drought, in some ways "\
|
|
370
|
+
"more extreme than the 2005 drought. The affected region was approximate 1,160,000 square "\
|
|
371
|
+
"miles (3,000,000 km2) of rainforest, compared to 734,000 square miles (1,900,000 km2) in "\
|
|
372
|
+
"2005. The 2010 drought had three epicenters where vegetation died off, whereas in 2005 the "\
|
|
373
|
+
"drought was focused on the southwestern part. The findings were published in the journal "\
|
|
374
|
+
"Science. In a typical year the Amazon absorbs 1.5 gigatons of carbon dioxide; during 2005 "\
|
|
375
|
+
"instead 5 gigatons were released and in 2010 8 gigatons were released."
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Text classification** requires only a query.
|
|
379
|
+
```bash
|
|
380
|
+
python scripts/nlp/text_classify_client.py --query "How much sun does california get?"
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
#### TTS
|
|
384
|
+
|
|
385
|
+
Call ``scripts/tts/talk.py`` script, and you will be prompted to enter a text for speech
|
|
386
|
+
synthesis. Set `--play-audio` option, and a synthesized speech will be played.
|
|
387
|
+
```bash
|
|
388
|
+
python scripts/tts/talk.py --play-audio
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
You can write output to file.
|
|
392
|
+
```bash
|
|
393
|
+
python scripts/tts/talk.py --output 'my_synth_speech.wav'
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
You can use streaming mode (audio fragments returned to client as soon as they are ready).
|
|
397
|
+
```bash
|
|
398
|
+
python scripts/tts/talk.py --stream --play-audio
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### API
|
|
402
|
+
|
|
403
|
+
See tutorial notebooks in directory `tutorials`.
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
## Documentation
|
|
407
|
+
|
|
408
|
+
Additional documentation on the Riva Speech Skills SDK can be found [here](https://docs.nvidia.com/deeplearning/riva/user-guide/docs/).
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
## License
|
|
412
|
+
|
|
413
|
+
This client code is MIT-licensed. See LICENSE file for full details.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
nvidia_riva_client-2.22.0.dist-info/licenses/LICENSE,sha256=nAu1MzYxnBPQYaIkbupPPyFrrTHN6x_J_w_Y2DCN1UM,1096
|
|
2
|
+
riva/client/__init__.py,sha256=kmu7kS7D7Vjb-HCNdD0_fsfBCJ-I7c0cjt2a6bf1bmg,1551
|
|
3
|
+
riva/client/argparse_utils.py,sha256=Jnhy6CtkvDvRdR-CxQvKakXzM7NiNlbdN7yDcp9On1s,5701
|
|
4
|
+
riva/client/asr.py,sha256=r1HzJtz7kjvjfRSJDtuZ6ndA0R4sHCdclx8CLjU6ntk,22641
|
|
5
|
+
riva/client/audio_io.py,sha256=IxarMvzYaXFZjao-rPaJI31BpwW4REn8jc7aQ71o_Cg,4080
|
|
6
|
+
riva/client/auth.py,sha256=xTS--xLjApscPISvDAyVAqUonljMihFOFuGDEchWdX4,6454
|
|
7
|
+
riva/client/health.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
riva/client/nlp.py,sha256=LXsEzVMwO7qWFMH4eOFQTmtXevuCKxzRRs28KtWIWdA,20537
|
|
9
|
+
riva/client/nmt.py,sha256=S3nATJEAhveMTJAnrV38Uw4zT_q0GREbJOajGOHUR7Q,9797
|
|
10
|
+
riva/client/package_info.py,sha256=WHnd0GXw_RwZKhCaUQHV8T5Jc-4Jw2BH_8inBdAlS6U,1021
|
|
11
|
+
riva/client/realtime.py,sha256=vde-EE0O-RKR3b9LksYIVdLriN7YJEd6ep1tksnanIM,20891
|
|
12
|
+
riva/client/tts.py,sha256=K5BZTImzlfHwQBw8GoD6VIbz6a8a9T6RlJ9Osg5cQRc,8048
|
|
13
|
+
riva/client/proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
riva/client/proto/health_pb2.py,sha256=sAkbVqOwmqm6H3s05XUWcUHgEi_n5ak9QRNPCyMz0mE,2288
|
|
15
|
+
riva/client/proto/health_pb2_grpc.py,sha256=qgd2XXHtpr5pRMSDhLgOBWvYSUOScNN94mr2ct6FvNg,5305
|
|
16
|
+
riva/client/proto/riva_asr_pb2.py,sha256=bjbA18qiozA_iYL1mGKf8kQBIC0VHv25OPCEVaQA3Ks,9631
|
|
17
|
+
riva/client/proto/riva_asr_pb2_grpc.py,sha256=PAgBm8aLKSqMQhPmOS2GlXcFPBxVdVXr_LTXCcNFKXg,8406
|
|
18
|
+
riva/client/proto/riva_audio_pb2.py,sha256=jA1516mytkj2XYAVogH3MvGZZ27Hn0HqGw74vmkOqdE,1632
|
|
19
|
+
riva/client/proto/riva_audio_pb2_grpc.py,sha256=7AA923pFme4iIfQ1gbgeoIaefbrGrXv7A2ZjGl3nxDM,902
|
|
20
|
+
riva/client/proto/riva_common_pb2.py,sha256=FDDqw1-RHZAjhe_HjiUUzivylElhTY-zwRCspD0Qrfk,1470
|
|
21
|
+
riva/client/proto/riva_common_pb2_grpc.py,sha256=oJtppsuIi-V3fdHsDFSWKXme_HjE0NPygX7EmmafgXs,903
|
|
22
|
+
riva/client/proto/riva_nlp_pb2.py,sha256=ctIVcfwYI0QQ1nAAR8LGZsHzRahEEbHUg_sy59Ow3vQ,19030
|
|
23
|
+
riva/client/proto/riva_nlp_pb2_grpc.py,sha256=EUuyuSE1GAlBnrqgRVDUGJesJIKtzvrufkIDIbGRjzY,18887
|
|
24
|
+
riva/client/proto/riva_nmt_pb2.py,sha256=laMC7_CuvXkYD10O0ayjrEmdiaPPAm67-3qyvxASm1w,7869
|
|
25
|
+
riva/client/proto/riva_nmt_pb2_grpc.py,sha256=CBktyLnEZjiNXyl6tfjdN8pcXLMP8N7Lv2SNUrdKBtw,10343
|
|
26
|
+
riva/client/proto/riva_tts_pb2.py,sha256=ga2biFohaQWcslv76PEOddSCNA5s1Sw1xm6hViYRBuE,4939
|
|
27
|
+
riva/client/proto/riva_tts_pb2_grpc.py,sha256=IXWwdWQ4Dz_pgI5pvHPaEUcf4PEHvDKX_Sa_EVp5gxs,8017
|
|
28
|
+
nvidia_riva_client-2.22.0.dist-info/METADATA,sha256=2-YmbYi8IHNxkEOvvtOZxXQsw_kBuoXqBaU_RDnewkQ,13208
|
|
29
|
+
nvidia_riva_client-2.22.0.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
|
|
30
|
+
nvidia_riva_client-2.22.0.dist-info/top_level.txt,sha256=TkNUc1bbS7wIfdAJ4f9Y-Yh57tJoas_DdKaB0UYEA4s,5
|
|
31
|
+
nvidia_riva_client-2.22.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
riva
|
riva/client/__init__.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
from riva.client.asr import (
|
|
5
|
+
AudioChunkFileIterator,
|
|
6
|
+
ASRService,
|
|
7
|
+
add_audio_file_specs_to_config,
|
|
8
|
+
add_word_boosting_to_config,
|
|
9
|
+
add_speaker_diarization_to_config,
|
|
10
|
+
get_wav_file_parameters,
|
|
11
|
+
print_offline,
|
|
12
|
+
print_streaming,
|
|
13
|
+
sleep_audio_length,
|
|
14
|
+
add_endpoint_parameters_to_config,
|
|
15
|
+
add_custom_configuration_to_config,
|
|
16
|
+
)
|
|
17
|
+
from riva.client.auth import Auth
|
|
18
|
+
from riva.client.nlp import (
|
|
19
|
+
NLPService,
|
|
20
|
+
extract_all_text_classes_and_confidences,
|
|
21
|
+
extract_all_token_classification_predictions,
|
|
22
|
+
extract_most_probable_text_class_and_confidence,
|
|
23
|
+
extract_most_probable_token_classification_predictions,
|
|
24
|
+
)
|
|
25
|
+
from riva.client.package_info import (
|
|
26
|
+
__contact_emails__,
|
|
27
|
+
__contact_names__,
|
|
28
|
+
__description__,
|
|
29
|
+
__download_url__,
|
|
30
|
+
__homepage__,
|
|
31
|
+
__keywords__,
|
|
32
|
+
__license__,
|
|
33
|
+
__package_name__,
|
|
34
|
+
__repository_url__,
|
|
35
|
+
__shortversion__,
|
|
36
|
+
__version__,
|
|
37
|
+
)
|
|
38
|
+
from riva.client.proto.riva_asr_pb2 import RecognitionConfig, StreamingRecognitionConfig, EndpointingConfig
|
|
39
|
+
from riva.client.proto.riva_audio_pb2 import AudioEncoding
|
|
40
|
+
from riva.client.proto.riva_nlp_pb2 import AnalyzeIntentOptions
|
|
41
|
+
from riva.client.proto.riva_nmt_pb2 import StreamingTranslateSpeechToSpeechConfig, TranslationConfig, SynthesizeSpeechConfig, StreamingTranslateSpeechToTextConfig
|
|
42
|
+
from riva.client.tts import SpeechSynthesisService
|
|
43
|
+
from riva.client.nmt import NeuralMachineTranslationClient
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
|
|
6
|
+
def validate_grpc_message_size(value):
|
|
7
|
+
"""Validate that the GRPC message size is within acceptable limits."""
|
|
8
|
+
min_size = 4 * 1024 * 1024 # 4MB
|
|
9
|
+
max_size = 1024 * 1024 * 1024 # 1GB
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
size = int(value)
|
|
13
|
+
if size < min_size:
|
|
14
|
+
raise argparse.ArgumentTypeError(f"GRPC message size must be at least {min_size} bytes (4MB)")
|
|
15
|
+
if size > max_size:
|
|
16
|
+
raise argparse.ArgumentTypeError(f"GRPC message size must be at most {max_size} bytes (1GB)")
|
|
17
|
+
return size
|
|
18
|
+
except ValueError:
|
|
19
|
+
raise argparse.ArgumentTypeError(f"'{value}' is not a valid integer")
|
|
20
|
+
|
|
21
|
+
def add_asr_config_argparse_parameters(
|
|
22
|
+
parser: argparse.ArgumentParser, max_alternatives: bool = False, profanity_filter: bool = False, word_time_offsets: bool = False
|
|
23
|
+
) -> argparse.ArgumentParser:
|
|
24
|
+
if word_time_offsets:
|
|
25
|
+
parser.add_argument(
|
|
26
|
+
"--word-time-offsets", default=False, action='store_true', help="Option to output word timestamps."
|
|
27
|
+
)
|
|
28
|
+
if max_alternatives:
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"--max-alternatives",
|
|
31
|
+
default=1,
|
|
32
|
+
type=int,
|
|
33
|
+
help="Maximum number of alternative transcripts to return (up to limit configured on server).",
|
|
34
|
+
)
|
|
35
|
+
if profanity_filter:
|
|
36
|
+
parser.add_argument(
|
|
37
|
+
"--profanity-filter",
|
|
38
|
+
default=False,
|
|
39
|
+
action='store_true',
|
|
40
|
+
help="Flag that controls the profanity filtering in the generated transcripts",
|
|
41
|
+
)
|
|
42
|
+
parser.add_argument(
|
|
43
|
+
"--automatic-punctuation",
|
|
44
|
+
default=False,
|
|
45
|
+
action='store_true',
|
|
46
|
+
help="Flag that controls if transcript should be automatically punctuated",
|
|
47
|
+
)
|
|
48
|
+
parser.add_argument(
|
|
49
|
+
"--no-verbatim-transcripts",
|
|
50
|
+
default=False,
|
|
51
|
+
action='store_true',
|
|
52
|
+
help="If specified, text inverse normalization will be applied",
|
|
53
|
+
)
|
|
54
|
+
parser.add_argument("--language-code", default="en-US", help="Language code of the model to be used.")
|
|
55
|
+
parser.add_argument("--model-name", default="", help="Model name to be used.")
|
|
56
|
+
parser.add_argument("--boosted-lm-words", action='append', help="Words to boost when decoding. Can be used multiple times to boost multiple words.")
|
|
57
|
+
parser.add_argument(
|
|
58
|
+
"--boosted-lm-score", type=float, default=4.0, help="Recommended range for the boost score is 20 to 100. The higher the boost score, the more biased the ASR engine is towards this word."
|
|
59
|
+
)
|
|
60
|
+
parser.add_argument(
|
|
61
|
+
"--speaker-diarization",
|
|
62
|
+
default=False,
|
|
63
|
+
action='store_true',
|
|
64
|
+
help="Flag that controls if speaker diarization should be performed",
|
|
65
|
+
)
|
|
66
|
+
parser.add_argument(
|
|
67
|
+
"--diarization-max-speakers",
|
|
68
|
+
default=3,
|
|
69
|
+
type=int,
|
|
70
|
+
help="Max number of speakers to detect when performing speaker diarization",
|
|
71
|
+
)
|
|
72
|
+
parser.add_argument(
|
|
73
|
+
"--start-history",
|
|
74
|
+
default=-1,
|
|
75
|
+
type=int,
|
|
76
|
+
help="Value (in milliseconds) to detect and initiate start of speech utterance",
|
|
77
|
+
)
|
|
78
|
+
parser.add_argument(
|
|
79
|
+
"--start-threshold",
|
|
80
|
+
default=-1.0,
|
|
81
|
+
type=float,
|
|
82
|
+
help="Threshold value for detecting the start of speech utterance",
|
|
83
|
+
)
|
|
84
|
+
parser.add_argument(
|
|
85
|
+
"--stop-history",
|
|
86
|
+
default=-1,
|
|
87
|
+
type=int,
|
|
88
|
+
help="Value (in milliseconds) to detect end of utterance and reset decoder",
|
|
89
|
+
)
|
|
90
|
+
parser.add_argument(
|
|
91
|
+
"--stop-threshold",
|
|
92
|
+
default=-1.0,
|
|
93
|
+
type=float,
|
|
94
|
+
help="Threshold value for detecting the end of speech utterance",
|
|
95
|
+
)
|
|
96
|
+
parser.add_argument(
|
|
97
|
+
"--stop-history-eou",
|
|
98
|
+
default=-1,
|
|
99
|
+
type=int,
|
|
100
|
+
help="Value (in milliseconds) to detect end of utterance for the 1st pass and generate an intermediate final transcript",
|
|
101
|
+
)
|
|
102
|
+
parser.add_argument(
|
|
103
|
+
"--stop-threshold-eou",
|
|
104
|
+
default=-1.0,
|
|
105
|
+
type=float,
|
|
106
|
+
help="Threshold value for likelihood of blanks before detecting end of utterance",
|
|
107
|
+
)
|
|
108
|
+
parser.add_argument(
|
|
109
|
+
"--custom-configuration",
|
|
110
|
+
default="",
|
|
111
|
+
type=str,
|
|
112
|
+
help="Custom configurations to be sent to the server as key value pairs <key:value,key:value,...>",
|
|
113
|
+
)
|
|
114
|
+
return parser
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def add_connection_argparse_parameters(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
|
|
118
|
+
parser.add_argument("--server", default="localhost:50051", help="URI to GRPC server endpoint.")
|
|
119
|
+
parser.add_argument("--ssl-root-cert", help="Path to SSL root certificates file.")
|
|
120
|
+
parser.add_argument("--ssl-client-cert", help="Path to SSL client certificates file.")
|
|
121
|
+
parser.add_argument("--ssl-client-key", help="Path to SSL client key file.")
|
|
122
|
+
parser.add_argument(
|
|
123
|
+
"--use-ssl", action='store_true', help="Boolean to control if SSL/TLS encryption should be used."
|
|
124
|
+
)
|
|
125
|
+
parser.add_argument("--metadata", action='append', nargs='+', help="Send HTTP Header(s) to server")
|
|
126
|
+
parser.add_argument("--options", action='append', nargs='+', help="Send GRPC options to server")
|
|
127
|
+
parser.add_argument(
|
|
128
|
+
"--max-message-length", type=validate_grpc_message_size, default=64 * 1024 * 1024, help="Maximum message length for GRPC server."
|
|
129
|
+
)
|
|
130
|
+
return parser
|
|
131
|
+
|
|
132
|
+
def add_realtime_config_argparse_parameters(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
|
|
133
|
+
parser.add_argument("--endpoint", default="/v1/realtime", help="Endpoint to WebSocket server endpoint.")
|
|
134
|
+
parser.add_argument("--query-params", default="intent=transcription", help="Query parameters to WebSocket server endpoint.")
|
|
135
|
+
return parser
|