Skip to content

Commit bec7a70

Browse files
authored
fix: wait for recognition to be done (#109)
1 parent 745516d commit bec7a70

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wyoming_microsoft_stt/microsoft_stt.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def recognized(event: speechsdk.SpeechRecognitionEventArgs):
8585
_LOGGER.debug(f"{event.result}")
8686
self._results = event.result
8787

88-
self._speech_recognizer.start_continuous_recognition()
8988
self._speech_recognizer.recognized.connect(recognized)
89+
self._speech_recognizer.start_continuous_recognition_async()
9090

9191
def push_audio_chunk(self, chunk: bytes) -> None:
9292
"""Push an audio chunk to the recognizer."""
@@ -107,7 +107,11 @@ def transcribe(self):
107107
while not self.recognition_done:
108108
time.sleep(0.01)
109109

110-
self._speech_recognizer.stop_continuous_recognition()
110+
out_future = self._speech_recognizer.stop_continuous_recognition_async()
111+
112+
out = out_future.get()
113+
114+
_LOGGER.debug(f"Transcription stopped, result: {out}")
111115

112116
if self._results is None:
113117
_LOGGER.debug("No results from transcription.")

0 commit comments

Comments
 (0)