Support specifying provider for python examples (#244)

This commit is contained in:
Fangjun Kuang
2023-08-09 10:00:34 +08:00
committed by GitHub
parent 6235cb9f1b
commit aeb112dd06
4 changed files with 35 additions and 1 deletions

View File

@@ -82,6 +82,13 @@ def get_args():
""",
)
parser.add_argument(
"--provider",
type=str,
default="cpu",
help="Valid values: cpu, cuda, coreml",
)
parser.add_argument(
"--bpe-model",
type=str,
@@ -148,10 +155,12 @@ def create_recognizer():
feature_dim=80,
decoding_method=args.decoding_method,
max_active_paths=args.max_active_paths,
provider=args.provider,
context_score=args.context_score,
)
return recognizer
def encode_contexts(args, contexts: List[str]) -> List[List[int]]:
sp = None
if "bpe" in args.modeling_unit:
@@ -172,6 +181,7 @@ def encode_contexts(args, contexts: List[str]) -> List[List[int]]:
tokens_table=tokens,
)
def main():
args = get_args()
@@ -205,6 +215,7 @@ def main():
last_result = result
print("\r{}".format(result), end="", flush=True)
if __name__ == "__main__":
devices = sd.query_devices()
print(devices)