Reputation: 11
I'm making a smart station on orangepi 3b on python3.10, put ubuntu 22.04 there, wrote the code, but the bad luck is that I don't play the audio file in the while loop, although everything works fine on the PC widows 11, everything also works outside the loop
while True:
data = stream.read(4096, exception_on_overflow=False)
if rec.AcceptWaveform(data):
result = json.loads(rec.Result())
print(result)
if result['text'].startswith('ник') and not is_recording:
print("Начало записи...")
outpute.wave('р.wav')
is_recording = True
elif is_recording and result['text'] == '':
print("Завершение записи")
is_recording = False
break
else:
print(json.loads(rec.PartialResult()))
if is_recording:
audio_data.extend(data)
The wave function
def wave(filename):
data, fs = sf.read(filename, dtype='float32')
sd.play(data, fs)
time.sleep(len(data)/fs)
sd.stop()
after starting, there is a delay, but there is no sound
please help me, I have a project protection coming soon
Upvotes: 0
Views: 37