Skip to content

Commit

Permalink
draft: update clients for separate utterances (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
virajkarandikar authored Mar 23, 2023
1 parent db77d10 commit e7b4c61
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion riva/client/asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ def print_streaming(
def print_offline(response: rasr.RecognizeResponse) -> None:
print(response)
if len(response.results) > 0 and len(response.results[0].alternatives) > 0:
print("Final transcript:", response.results[0].alternatives[0].transcript)
final_transcript = ""
for res in response.results:
final_transcript += res.alternatives[0].transcript
print("Final transcript:", final_transcript)


def streaming_request_generator(
Expand Down
2 changes: 1 addition & 1 deletion scripts/asr/transcribe_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def parse_args() -> argparse.Namespace:
"--print-confidence", action="store_true", help="Whether to print stability and confidence of transcript."
)
parser = add_connection_argparse_parameters(parser)
parser = add_asr_config_argparse_parameters(parser, profanity_filter=True)
parser = add_asr_config_argparse_parameters(parser, max_alternatives=True, profanity_filter=True, word_time_offsets=True)
args = parser.parse_args()
if not args.list_devices and args.input_file is None:
parser.error(
Expand Down
4 changes: 2 additions & 2 deletions scripts/asr/transcribe_file_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def parse_args() -> argparse.Namespace:
)
parser.add_argument("--input-file", required=True, type=Path, help="A path to a local file to transcribe.")
parser = add_connection_argparse_parameters(parser)
parser = add_asr_config_argparse_parameters(parser, profanity_filter=True, word_time_offsets=True)
parser = add_asr_config_argparse_parameters(parser, max_alternatives=True, profanity_filter=True, word_time_offsets=True)
args = parser.parse_args()
args.input_file = args.input_file.expanduser()
return args
Expand All @@ -31,7 +31,7 @@ def main() -> None:
config = riva.client.RecognitionConfig(
encoding=riva.client.AudioEncoding.LINEAR_PCM,
language_code=args.language_code,
max_alternatives=1,
max_alternatives=args.max_alternatives,
profanity_filter=args.profanity_filter,
enable_automatic_punctuation=args.automatic_punctuation,
verbatim_transcripts=not args.no_verbatim_transcripts,
Expand Down

0 comments on commit e7b4c61

Please sign in to comment.