I’ve followed the Riva quickstart guide to deploy the default English ASR model. When I use the CLI, Riva produces the correct results for streaming. However, when I use the following script, the results are incomplete and the final result is empty. Please let me know what could be wrong here.
import riva.client
from copy import deepcopy
uri = "localhost:50051"
auth = riva.client.Auth(uri=uri)
asr_service = riva.client.ASRService(auth)
offline_config = riva.client.RecognitionConfig(language_code="en-US",encoding=riva.client.AudioEncoding.LINEAR_PCM)
streaming_config = riva.client.StreamingRecognitionConfig(config=deepcopy(offline_config), interim_results=True)
def interpret(consumed_message_value):
audio_file_path="/opt/riva/wav/en-US_sample.wav"
error_msg=""
if error_msg:
print(error_msg)
return
riva.client.add_audio_file_specs_to_config(streaming_config, audio_file_path)
wav_parameters = riva.client.get_wav_file_parameters(audio_file_path)
# correponds to 1 second of audio
chunk_size = wav_parameters['framerate']
audio_chunk_iterator = riva.client.AudioChunkFileIterator(audio_file_path, chunk_size)
response_generator = asr_service.streaming_response_generator(audio_chunk_iterator, streaming_config)
riva.client.print_streaming(response_generator, additional_info='confidence')
interpret(consumed_message_value={})
The output is:
>> what
Stability: 0.1000
----
>> what
Stability: 0.1000
----
>> what is
Stability: 0.1000
----
>> what is
Stability: 0.1000
----
>> what is
Stability: 0.1000
----
>> what is now
Stability: 0.1000
----
>> what is natural
Stability: 0.1000
----
>> what is natural
Stability: 0.1000
----
>> what is natural language
Stability: 0.1000
----
>> what is natural language
Stability: 0.1000
----
>> what is natural language
Stability: 0.1000
----
>> what is natural language
Stability: 0.1000
----
>> what
Stability: 0.9000
>> is natural language Processing
Stability: 0.1000
----
>> what
Stability: 0.9000
>> is natural language Processing
Stability: 0.1000
----
>> what is
Stability: 0.9000
>> natural language Processing
Stability: 0.1000
----
>> what is
Stability: 0.9000
>> natural language Processing
Stability: 0.1000
----
>> what is
Stability: 0.9000
>> natural language Processing
Stability: 0.1000
----
>> what is
Stability: 0.9000
>> language Processing
Stability: 0.1000
----
>> what is
Stability: 0.9000
>> language Processing
Stability: 0.1000
----
----
Expected output should contain the following line according to my understanding:
## What is Natural Language Processing?
Confidence: <some floating value>