How to send a single input_audio_file as an input to the assistant and get responses as and when the input file content changes (runtime)? #237
Description
I am using the pushtotalk sample with file input and speaker output. I have the input file created(input.wav) and pass that to the assistant (python -m pushtotalk -i input.wav) -> This plays back the correct assistant response once and stops. I am using PyAudio to do the recording for the input file.
I have modified the code, to ask for user input(Press Enter to start recording....) and once the user hits a key, the assistant API unpacks the input audio file(input.wav) and plays back the response and stays in the loop.
I keep the loop open, since I do not want to establish a gRPC connection channel each time, to run the file input.
So, for the next iteration, when the audio input content changes(input.wav), how to make the assistant playback the response for the updated (input.wav) ?
Note: Sequence explained:
input.wav -> "How's the weather in palo alto california?" (initial recording)
(env) python -m pushtotalk -i input.wav
Press Enter to send a new request......
<--- Hit enter
unpacks the audio and plays the response
assistant: Playback Response: (Currently in palo alto california, its 59 degrees Farenheit and cloudy. Today it'll be partly cloudy, with a forecasted high of 74 and a low of 49.
once the playback is finished, it asks for user input (similar to running the live microphone input sample)
Press Enter to send a new request ........
Now, I open another terminal and record a new input.wav in the same path
input.wav (new) -> "Tell me a joke"
(env) So, back in the Google Assistant SDK running terminal, if I hit Enter, It does not unpack the new input audio and play the response for the Joke request.
Instead it says recording......, and iterates for a few seconds and ends the recording, with no output.
The reason I am doing this is, I do not want to establish a connection each time to run a file input sample.
Instead, the connection should be open and whenever a user interacts, should unpack the audio and play the response.
Is there a way to do this? Any help would be much appreciated?