I don't know how to print the output of Riva

Hi

I’m trying Riva.
I got Riva 2.12.0 working with Jetson Agx Orin.
I was able to use transcribe_mic.py to ASR the voice input from the microphone and see the text appear in the terminal.
But this is just a demo.
I want to process the text after ASR.

I think that the text is displayed by the following process, but how can I, for example, create a new variable and copy the text into that variable?

Could you please write the code as a sample?

        riva.client.print_streaming(
            responses=asr_service.streaming_response_generator(
                audio_chunks=audio_chunk_iterator,
                streaming_config=config,
            ),
            show_intermediate=True,
        )

Help Me!

HI @Heartful-echo

Thanks for your interest in Riva

It is also possible to print streaming results in several places, e.g. in STDOUT and also on a file. you can store it in a file and load it into a variable

import sys
output_file = "my_results.txt"

riva.client.print_streaming(
            responses=asr_service.streaming_response_generator(
                audio_chunks=audio_chunk_iterator,
                streaming_config=config,
            ),
            show_intermediate=True,output_file=[sys.stdout, output_file]
        )

Thanks

@rvinobha

Thank you for your advice!!

I tried it right away.

my_results.txt was created when I ran transcribe_mic.py.
I spoke into the microphone.
The terminal displays ## followed by the conversation as text.
I think this is displaying text by sys.stdout.

At this time, the content of my_results.txt is blank.
When I stopped the execution of transcribe_mic.py with Ctrl +C, the text was written to my_results.txt.

I want to pass the ASR result text to other applications based on transcribe_mic.py. I think I can pass it in my_results.txt like this time, but I would like to know when the ASR result text is written in my_results.txt.

Will it not be written unless transcribe_mic.py is stopped?

Thank you.

Hi

I was able to obtain Riva’s output results using the following method.
thank you very much.

    riva.client.add_word_boosting_to_config(config, args.boosted_lm_words, args.boosted_lm_score)
    with riva.client.audio_io.MicrophoneStream(
        args.sample_rate_hz,
        args.file_streaming_chunk,
        device=args.input_device,
    ) as audio_chunk_iterator:

        responses = asr_service.streaming_response_generator(
            audio_chunks=audio_chunk_iterator,
            streaming_config=config,
        )

        for response in responses:
            if response.results:
                transcript_text = response.results[0].alternatives[0].transcript
                print(transcript_text)
            else:
                print("Transcript data not available")

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.