Skip to content

Commit

Permalink
Add hotwords for python examples (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Dec 7, 2023
1 parent 9fd92b3 commit a96bbea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python-api-examples/decode-file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions python-api-examples/speech-recognition-from-microphone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a96bbea

Please sign in to comment.