Closed osmadja closed 6 years ago
Please don't copy-paste large amount of code to the issue and I certainly won't be able to make time to read through all this.
You probably want to have one instance and feed the audio yourself to porcupine and then google api. that should work.
@osmadja did you ever complete your script? I'm trying to do the same thing.
This dirty code combines Porcupine and Google Cloud Speech, made for improvement.
This dirty code combines Porcupine and Google Cloud Speech, made for improvement.
Thanks. I'll probably try it at some point.
I'm trying to use Porcupine wake word detection as a trigger for Google Speech API.
This is not exactly an issue. I am looking for orientation about the best way to use Porcupine to trigger Google Speech API using Python.
The problem seems to be in the fact that both Porcupine and Google Speech Calls use PyAudio.
I used the python Porcupine demo code as a basis and then call the google speech api.
It is not clear if I need to create a new PyAudio instance to call Google Speech API or If I could "share" the same PyAudio instance.
When terminating the Porcupine PyAudio instance (pa.terminate()) and creating a new Pyaudio instance for Google Speech Api, it seems to work. I then need to recreate an instance of PyAudio for Porcupine. It works a few times and then starts to stop in the porcupine demo 'while True' loop).
I also tried sharing the porcupine pyaudio instance( after changing the pyAudio parameters to the ones recommended by Google).
It works once : i can call the google speech API and it return correctly but then raise the following error when the pyAudio instance is reused by Porcupine :
Expected behavior
After detecting a wake work, it should call the google speech api.
Actual behavior
It stops after a few Api calls
Steps to reproduce the behavior
Configure google credential :
replace the amigo_mac.ppn with your own wake word file
Execute :
Say the word , wait to see "* detected keyword" on the console and then say any other text (that should be recognized by google api).
Repeat this 5 times to see the problem happening.
porcupine_demo_gvoice.py
vr.py : Google Speech API calls
File asr.ini : Configuration file to define wich microphone to be used : out the usb microphone name. Put this file in the same directory as the py files.