diff --git a/requirements.txt b/requirements.txt index bc679f4..8a6ee6e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ sphinx sphinx_rtd_theme pre-commit python-dotenv +numpy<=1.16.6 diff --git a/src/robot_interface/endpoints/audio_sender.py b/src/robot_interface/endpoints/audio_sender.py index 86dc66c..e168285 100644 --- a/src/robot_interface/endpoints/audio_sender.py +++ b/src/robot_interface/endpoints/audio_sender.py @@ -37,7 +37,6 @@ class AudioCapturer(object): @abstractmethod def generate_chunk(self): raise NotImplementedError() - class QiAudioCapturer(AudioCapturer): @@ -69,15 +68,13 @@ class QiAudioCapturer(AudioCapturer): except: pass - - def audio_gen(self): + def generate_chunk(self): try: chunk = self.q.get(True, 0.1) return chunk except Queue.Empty: return None - # Callback invoked by NAOqi def processRemote(self, nbOfChannels, nbOfSamplesByChannel, timeStamp, inputBuffer): raw_pcm = bytes(inputBuffer) @@ -91,10 +88,11 @@ class QiAudioCapturer(AudioCapturer): pcm_f32 = np.append(self.overflow, pcm_f32) for i in range(len(pcm_f32) // 512): - self.q.put_nowait(pcm_f32[i * 512 : (i + 1) * 512]) + self.q.put_nowait(pcm_f32[i * 512 : (i + 1) * 512].tobytes()) self.overflow = pcm_f32[len(pcm_f32) // 512 * 512 :] + class StandaloneAudioCapturer: pass @@ -108,8 +106,8 @@ class AudioSender(SocketBase): self.capturer = self.choose_capturer() - def start(self): + self.capturer.setup() self.thread.start() def close(self): @@ -120,7 +118,7 @@ class AudioSender(SocketBase): while not state.exit_event.is_set(): chunk = self.capturer.generate_chunk() - if not chunk or state.is_speaking: + if chunk is None or state.is_speaking: continue self.socket.send(chunk)