Overview
Running the microphone-speech-to-text.py example hangs after CTRL-C to exit on Raspberry Pi. This is because the statements in the Except block are in the wrong order. Solution is below.
Expected behavior
The program should exit normally
Actual behavior
The program hangs when CTRL-C is pressed
How to reproduce
Run the program as is. This is on a Raspberry Pi with Python3. Also tested on MacOS 10.14.4, but it does not hang.
SDK Version
v3.0.3
Additional information:
Raspbian, Python3
Additional context
The solution is to shutdown the services in reverse order in which they were created. This was tested on Raspi. The correct order is below (current code commented out):
except KeyboardInterrupt:
# stop recording
# audio_source.completed_recording()
# stream.stop_stream()
# stream.close()
# audio.terminate()
stream.stop_stream()
stream.close()
audio.terminate()
audio_source.completed_recording()
Overview
Running the microphone-speech-to-text.py example hangs after CTRL-C to exit on Raspberry Pi. This is because the statements in the Except block are in the wrong order. Solution is below.
Expected behavior
The program should exit normally
Actual behavior
The program hangs when CTRL-C is pressed
How to reproduce
Run the program as is. This is on a Raspberry Pi with Python3. Also tested on MacOS 10.14.4, but it does not hang.
SDK Version
v3.0.3
Additional information:
Raspbian, Python3
Additional context
The solution is to shutdown the services in reverse order in which they were created. This was tested on Raspi. The correct order is below (current code commented out):