Fix displaying streaming speech recognition results for Python. (#2196)
This commit is contained in:
@@ -192,8 +192,7 @@ def main():
|
||||
|
||||
stream = recognizer.create_stream()
|
||||
|
||||
last_result = ""
|
||||
segment_id = 0
|
||||
display = sherpa_onnx.Display()
|
||||
|
||||
print("Started!")
|
||||
while True:
|
||||
@@ -213,13 +212,14 @@ def main():
|
||||
|
||||
result = recognizer.get_result(stream)
|
||||
|
||||
if result and (last_result != result):
|
||||
last_result = result
|
||||
print("\r{}:{}".format(segment_id, result), end="", flush=True)
|
||||
display.update_text(result)
|
||||
display.display()
|
||||
|
||||
if is_endpoint:
|
||||
if result:
|
||||
print("\r{}:{}".format(segment_id, result), flush=True)
|
||||
segment_id += 1
|
||||
display.finalize_current_sentence()
|
||||
display.display()
|
||||
|
||||
recognizer.reset(stream)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user