-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathargparse_utils.py
More file actions
78 lines (73 loc) · 3.12 KB
/
argparse_utils.py
File metadata and controls
78 lines (73 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: MIT
import argparse
import riva.client
def add_asr_config_argparse_parameters(
parser: argparse.ArgumentParser,
max_alternatives: bool = False,
profanity_filter: bool = False,
word_time_offsets: bool = False,
) -> argparse.ArgumentParser:
if word_time_offsets:
parser.add_argument(
"--word-time-offsets", default=False, action='store_true', help="Option to output word timestamps."
)
if max_alternatives:
parser.add_argument(
"--max-alternatives",
default=1,
type=int,
help="Maximum number of alternative transcripts to return (up to limit configured on server).",
)
if profanity_filter:
parser.add_argument(
"--profanity-filter",
default=False,
action='store_true',
help="Flag that controls the profanity filtering in the generated transcripts",
)
parser.add_argument(
"--encoding",
type=int,
default=riva.client.AudioEncoding.Value('ENCODING_UNSPECIFIED'),
help=f"Encoding of the audio data. Supported values are {riva.client.AudioEncoding.items()}",
)
parser.add_argument(
"--sample-rate-hertz", type=int, default=None, help=f"Sample rate in Hz of the audio data",
)
parser.add_argument(
"--audio-channel-count", type=int, default=None, help=f"Channel count of the audio data",
)
parser.add_argument(
"--automatic-punctuation",
default=False,
action='store_true',
help="Flag that controls if transcript should be automatically punctuated",
)
parser.add_argument(
"--verbatim-transcripts",
default=False,
action='store_true',
help="Flag to disable Inverse Text Normalization (ITN) and return the text exactly as it was said",
)
parser.add_argument("--model-name", default="", help="Name of the model to be used to be used.")
parser.add_argument("--language-code", default="en-US", help="Language code of the model to be used.")
parser.add_argument("--boosted-lm-words", action='append', help="Words to boost when decoding.")
parser.add_argument(
"--boosted-lm-score", type=float, default=4.0, help="Value by which to boost words when decoding."
)
parser.add_argument(
"--speaker-diarization",
default=False,
action='store_true',
help="Flag that controls if speaker diarization should be performed",
)
return parser
def add_connection_argparse_parameters(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
parser.add_argument("--server", default="localhost:50051", help="URI to GRPC server endpoint.")
parser.add_argument("--ssl-cert", help="Path to SSL client certificates file.")
parser.add_argument(
"--use-ssl", action='store_true', help="Boolean to control if SSL/TLS encryption should be used."
)
parser.add_argument("--metadata", action='append', nargs='+', help="Send HTTP Header(s) to server")
return parser