From a96bbea0be3dd2ccea254248927b25511320b350 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Thu, 7 Dec 2023 17:21:30 +0800 Subject: [PATCH] Add hotwords for python examples (#285) --- python-api-examples/decode-file.py | 2 ++ ...eech-recognition-from-microphone-with-endpoint-detection.py | 3 ++- python-api-examples/speech-recognition-from-microphone.py | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/python-api-examples/decode-file.py b/python-api-examples/decode-file.py index 009bbc56..15cb5d68 100755 --- a/python-api-examples/decode-file.py +++ b/python-api-examples/decode-file.py @@ -29,6 +29,8 @@ def main(): joiner_param="./sherpa-ncnn-conv-emformer-transducer-2022-12-06/joiner_jit_trace-pnnx.ncnn.param", joiner_bin="./sherpa-ncnn-conv-emformer-transducer-2022-12-06/joiner_jit_trace-pnnx.ncnn.bin", num_threads=4, + hotwords_file="", + hotwords_score=1.5, ) filename = "./sherpa-ncnn-conv-emformer-transducer-2022-12-06/test_wavs/1.wav" diff --git a/python-api-examples/speech-recognition-from-microphone-with-endpoint-detection.py b/python-api-examples/speech-recognition-from-microphone-with-endpoint-detection.py index c0dccdb6..3562db3f 100755 --- a/python-api-examples/speech-recognition-from-microphone-with-endpoint-detection.py +++ b/python-api-examples/speech-recognition-from-microphone-with-endpoint-detection.py @@ -40,6 +40,8 @@ def create_recognizer(): rule1_min_trailing_silence=2.4, rule2_min_trailing_silence=1.2, rule3_min_utterance_length=300, + hotwords_file="", + hotwords_score=1.5, ) return recognizer @@ -52,7 +54,6 @@ def main(): last_result = "" segment_id = 0 - with sd.InputStream(channels=1, dtype="float32", samplerate=sample_rate) as s: while True: samples, _ = s.read(samples_per_read) # a blocking read diff --git a/python-api-examples/speech-recognition-from-microphone.py b/python-api-examples/speech-recognition-from-microphone.py index f1cb071a..97e90e8c 100755 --- a/python-api-examples/speech-recognition-from-microphone.py +++ b/python-api-examples/speech-recognition-from-microphone.py @@ -34,6 +34,8 @@ def create_recognizer(): joiner_param="./sherpa-ncnn-conv-emformer-transducer-2022-12-06/joiner_jit_trace-pnnx.ncnn.param", joiner_bin="./sherpa-ncnn-conv-emformer-transducer-2022-12-06/joiner_jit_trace-pnnx.ncnn.bin", num_threads=4, + hotwords_file="", + hotwords_score=1.5, ) return recognizer