Mycroft Community Forum

Catch and print what User Said

Hi,

What would be the best way to catch what user said? I was looking into the message bus but that seems to only catch what Mycroft says?

I’m still a beginner with Mycroft skills development, and I saw an older skill which transcribed dictation to text but could not really figure out how it works.

Thanks in advance for any leads.

1 Like

Hi

The recognizer_loop:utterance message can be used to get the users utterances.

An example using the mycroft_bus_client module:

from mycroft_bus_client import MessageBusClient                                 
                                                                                
print('Setting up client to connect to a local mycroft instance')               
client = MessageBusClient()                                                     
                                                                                
def print_user_utterance(message):                                              
    print('The user said "{}"'.format(message.data.get('utterances')[0]))       
                                                                                
                                                                                
print('Registering handler for recorded speech message...')                     
client.on('recognizer_loop:utterance', print_user_utterance)                    
                                                                                
client.run_forever()
2 Likes

Ah, amazing! So it is possible via the message bus client; thanks so much!

1 Like