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