I hope this saves someone some time, sometime When using precise_runner on the Pinephone (aarch64) the process will crash when reading from the microphone due to the use of a hard-coded sampling rate when initializing the stream.
2020-12-22 17:02:49 :: kalliope-0.7.0 :: Say something!
Exception in thread Thread-3:
Traceback (most recent call last):
File “/usr/lib/python3.9/threading.py”, line 954, in _bootstrap_inner
File “/usr/lib/python3.9/threading.py”, line 892, in run
File “/usr/lib/python3.8/site-packages/precise_runner/runner.py”, line 231, in _handle_predictions
chunk = self.stream.read(self.chunk_size)
File “/usr/lib/python3.8/site-packages/precise_runner/runner.py”, line 186, in
stream.read = lambda x: pyaudio.Stream.read(stream, x // 2, False)
File “/usr/lib/python3.9/site-packages/pyaudio.py”, line 608, in read
return pa.read_stream(self._stream, num_frames, exception_on_overflow)
OSError: [Errno -9999] Unanticipated host error
Another Kalliope process returns “Invalid number of frames” from the exact same call. The problem also occurs when using the speech_recognition module directly and even when not using python. The alsa utility arecord with default values has the same issue.
“”“Start listening from stream”""
if self.stream is None:
from pyaudio import PyAudio, paInt16
self.pa = PyAudio()
self.stream = self.pa.open(
16000, 1, paInt16, True, frames_per_buffer=self.chunk_size
Changing the 16000 to (12000 and below) or (24000 and above) prevents the problem from occurring.