mirror of
https://github.com/dscripka/openWakeWord.git
synced 2026-08-27 18:17:20 -04:00
22 lines
No EOL
484 B
Python
22 lines
No EOL
484 B
Python
import pyaudio
|
|
import wave
|
|
|
|
def playBeep(file_path, audio):
|
|
CHUNK = 1024
|
|
|
|
wf = wave.open(file_path, 'rb')
|
|
|
|
|
|
stream = audio.open(format=audio.get_format_from_width(wf.getsampwidth()),
|
|
channels=wf.getnchannels(),
|
|
rate=wf.getframerate(),
|
|
output=True)
|
|
|
|
data = wf.readframes(CHUNK)
|
|
|
|
while data != b'':
|
|
stream.write(data)
|
|
data = wf.readframes(CHUNK)
|
|
|
|
stream.stop_stream()
|
|
stream.close() |