WAKEWORD RuntimeError: IOLoop is already running

Hello,

I am using matrix voice to do a conversational agent. this agent has a wake word using your tutorial https://matrix-io.github.io/matrix-documentation/matrix-core/python-examples/wakeword/ (in python)
and then once the word is detected, it passes to another file to start the conversation using kernel modules from this tutorial https://matrix-io.github.io/matrix-documentation/matrix-voice/resources/microphone/
both scripts work perfectly fine alone however when I call the wake word which will take me to the conversational script, the microphone stops hearing.
I think the problem is that the microphone of the wake word is still on recognition so i tried to stop the recognition service doing a function like this

def stopwakewordservice():
   # Define zmq socket
context = zmq.Context()
# Create a Pusher socket
socket = context.socket(zmq.PUSH)
# Connect Pusher to configuration socket
socket.connect('tcp://{0}:{1}'.format(matrix_ip, wakeword_port))

# Create a new driver config
config = driver_pb2.DriverConfig()

# Enable verbose option
config.wakeword.stop_recognition=True

# Send driver configuration through ZMQ socket
socket.send(config.SerializeToString())
print ('stop wake words for wakewords')

and then i added to your function in your tutorial this

def wakeword_data_callback(data):
# Extract data
data = io_pb2.WakeWordParams().FromString(data[0])
# Log data 
print('{0}'.format(data))
# Run actions based on the phrase heard
# CHANGE TO YOUR PHRASE
if data.wake_word == 'WAKE UP':
    print ('I HEARD WAKE UP START!\n')
    stopwakewordservice()
    
    conversationalagent.main() # this will go to the main script where the user can have a conversation with the matrix voice. 
   
    
    config_socket() #wakeword service is enabled again
    Process(target=register_data_callback, args=(wakeword_data_callback, matrix_ip, wakeword_port)).start()

as a result, the script where it contains my voice recognition and conversational agents works, however, I get an error RuntimeError: IOLoop is already running which I understand that the async process of the wake word is still running. is stopping the wake word service and then re-enable it is wrong? should I stop the async loop? how? how can I turn off only the microphones of the wake word and then reopen them?? is there a solution where you can help me. HOW??

please and thank you…

? how can I make the wake word work and matrix Hal for microphones together without getting this error???

Hi @jean,

Apologies for the delayed response!

This Pocketsphinx example is actually very old, and will soon be deprecated. It might be best for you to try a different wake word service like Snips. We have a simple tutorial for Snips here, and several other project examples with Snips here.

For a MATRIX Voice conversational agent, Snips will be very reliable. It is well supported, and has a massive community.

I hope this helps, and you are able to get your voice agent running with Snips!

Best,
Samreen