beep on activation WIP

This commit is contained in:
Bartmoss 2023-01-29 22:31:45 +01:00
parent 1f0ee10efe
commit 1e93daa4aa
3 changed files with 30 additions and 1 deletions

25
examples/utils/beep.py Normal file
View file

@ -0,0 +1,25 @@
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()