Skip to content

Commit e7b4c61

Browse files
draft: update clients for separate utterances (#38)
1 parent db77d10 commit e7b4c61

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

riva/client/asr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ def print_streaming(
253253
def print_offline(response: rasr.RecognizeResponse) -> None:
254254
print(response)
255255
if len(response.results) > 0 and len(response.results[0].alternatives) > 0:
256-
print("Final transcript:", response.results[0].alternatives[0].transcript)
256+
final_transcript = ""
257+
for res in response.results:
258+
final_transcript += res.alternatives[0].transcript
259+
print("Final transcript:", final_transcript)
257260

258261

259262
def streaming_request_generator(

scripts/asr/transcribe_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def parse_args() -> argparse.Namespace:
4949
"--print-confidence", action="store_true", help="Whether to print stability and confidence of transcript."
5050
)
5151
parser = add_connection_argparse_parameters(parser)
52-
parser = add_asr_config_argparse_parameters(parser, profanity_filter=True)
52+
parser = add_asr_config_argparse_parameters(parser, max_alternatives=True, profanity_filter=True, word_time_offsets=True)
5353
args = parser.parse_args()
5454
if not args.list_devices and args.input_file is None:
5555
parser.error(

scripts/asr/transcribe_file_offline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def parse_args() -> argparse.Namespace:
1818
)
1919
parser.add_argument("--input-file", required=True, type=Path, help="A path to a local file to transcribe.")
2020
parser = add_connection_argparse_parameters(parser)
21-
parser = add_asr_config_argparse_parameters(parser, profanity_filter=True, word_time_offsets=True)
21+
parser = add_asr_config_argparse_parameters(parser, max_alternatives=True, profanity_filter=True, word_time_offsets=True)
2222
args = parser.parse_args()
2323
args.input_file = args.input_file.expanduser()
2424
return args
@@ -31,7 +31,7 @@ def main() -> None:
3131
config = riva.client.RecognitionConfig(
3232
encoding=riva.client.AudioEncoding.LINEAR_PCM,
3333
language_code=args.language_code,
34-
max_alternatives=1,
34+
max_alternatives=args.max_alternatives,
3535
profanity_filter=args.profanity_filter,
3636
enable_automatic_punctuation=args.automatic_punctuation,
3737
verbatim_transcripts=not args.no_verbatim_transcripts,

0 commit comments

Comments
 (0)