MCPcopy Create free account
hub / github.com/RobotTelevision/CrowAssistant / wavethread

Function wavethread

CrowAssistant.py:269–303  ·  view source on GitHub ↗
(wavefile)

Source from the content-addressed store, hash-verified

267 #print("end of fun")
268
269def wavethread(wavefile):
270 global wf # Make wf global so it can be accessed by callback
271 global is_playing
272 global outputdev
273 is_playing = True
274 # Open the wav file
275 wf = wave.open(wavefile, 'rb')
276
277 p = pyaudio.PyAudio()
278 RATE = wf.getframerate()
279 CHUNK = int(RATE / 10)
280
281 stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
282 channels=wf.getnchannels(),
283 rate=RATE,
284 output=True,
285 output_device_index=outputdev,
286 frames_per_buffer=CHUNK,
287 stream_callback=callback)
288
289 # Start the stream
290 stream.start_stream()
291
292 # Keep the script running while the audio is playing
293 while stream.is_active():
294 time.sleep(0.1)
295
296 # Stop stream
297 stream.stop_stream()
298 stream.close()
299
300 # Close PyAudio and wave file
301 wf.close()
302 p.terminate()
303 is_playing=False
304
305
306def process_text(text):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected