say and play_wav failing after invoking CloudSpeechClient client.recognize method
jeffreywl opened this issue · 0 comments
Thank you for looking at this question. I am encountering failure of the say and play_wav functions after invoking the client.recognize method of CloudSpeechClient. I've not been able to find the cause. This pertains to the following environment:
VoiceHat Version 1
Raspberry Pi 3B+
OS: aiyprojects-2021-04-02
27 Aug - I discovered that if the RPI desktop PulseAudio Volume Control is open when I run this test the code executes as expected. In fact, none of the voicehat disable / enable entries appear in syslog, only an initial enable from PulseAudio Volume Control. Not a real fix to the issue - any help toward that end is appreciated.
If the sample code below is run with the client.recognize and print statements commented out, it will run continuously with no errors. With those lines included and executing, following calls to the say and play_wav functions do not work. No errors are returned by python, though the following syslog entries (tail -f syslog | grep voicehat) are interesting:
- Aug 26 13:50:43 raspberrypi kernel: [ 6007.519691] voicehat-codec voicehat-codec: Enabling audio amp...
- Aug 26 13:50:52 raspberrypi kernel: [ 6016.653097] voicehat-codec voicehat-codec: Enabling audio amp...
- Aug 26 13:51:00 raspberrypi kernel: [ 6024.749962] voicehat-codec voicehat-codec: Disabling audio amp...
Line 1 corresponds to the first say call
Line 2 seems to occur at the end of the recognize period
Line 3 occurs partially through the 2nd play call, no further enable is encountered and say and play_wav no longer produce any audio output.
Thanks again for looking at his. Any ideas are greatly appreciated!
Jeff
--------------------------------- sample code -----------------------
`#!/usr/bin/env python3.7
import argparse
import locale
import logging
from aiy.voice.tts import say
from aiy.voice.audio import AudioFormat, play_wav, record_file
from aiy.cloudspeech import CloudSpeechClient
def main():
client = CloudSpeechClient()
while True:
first say call
say("this is step 1 of the series of tests to examine audio output behavior one two three four five", volume=30)
play_wav('/home/pi/Sounds/chime.wav')
logging.info('at recognize step')
text = client.recognize()
print('received text: ',text)
second say call
say("this is step 2 of the series of tests to examine audio output behavior one two three four five", volume=30)
play_wav('/home/pi/Sounds/sweep.wav')
third say call
say("this is step 3 of the series of tests to examine audio output behavior one two three four five")
play_wav('/home/pi/Sounds/sweep.wav')
if name == 'main':
main()`