I am using pexpect in python to receive continuous audio data from an audio input for my home automation project. Is there a way to pause the pexpect from using my audio device? Or can I use the audio device in two separate programs/scripts?
What I want to do is: Use speech recognition (julius) to listen for keywords. For more complex commands I want to use Google's Speech to Text API because of a higher accuracy. Both things work perfectly fine separately. 
What my problem is: Once the keyword is found, audio data needs to be recorded and send to the Google API. However, I have only one audio device and this is already used by the speech recognition with julius. I cannot .close and .spawn the speech recognition, because it takes a long time to load. Is there any chance the pexpect can be paused? Or do you guys know any other workaround?
Bests,
MGG
A workaround for my problem was the following:
using dsnoop for ALSA audio settings in .asoundrc.
python pause pexpect.spawn and its used devices