MCPcopy Index your code
hub / github.com/NyarchLinux/DesktopPuppet / speak

Method speak

puppet_extension.py:243–258  ·  view source on GitHub ↗
(self, path: str, tts: TTSHandler, frame_rate: int)

Source from the content-addressed store, hash-verified

241 requests.post(f'{self.base_url}/set_overlay', json={'expression': overlay})
242
243 def speak(self, path: str, tts: TTSHandler, frame_rate: int):
244 tts.stop()
245 if self.get_setting("automatic_hide"):
246 self.set_overlay("overlay")
247 audio = AudioSegment.from_file(path)
248 sample_rate = audio.frame_rate
249 audio_data = audio.get_array_of_samples()
250 amplitudes = LivePNG.calculate_amplitudes(sample_rate, audio_data, frame_rate=frame_rate)
251 t1 = threading.Thread(target=self._start_animation, args=(amplitudes, frame_rate))
252 t2 = threading.Thread(target=tts.playsound, args=(path, ))
253 t1.start()
254 t2.start()
255 t1.join()
256 t2.join()
257 if self.get_setting("automatic_hide"):
258 self.set_overlay("background")
259
260 def _start_animation(self, amplitudes: list[float], frame_rate=10):
261 max_amplitude = max(amplitudes)

Callers

nothing calls this directly

Calls 1

set_overlayMethod · 0.95

Tested by

no test coverage detected