Speak to assist and/or ollama with just a mic and python in less than 10min

hi everyone i made a small python script to speak to assist and if a media_player is configured it will redirect the audio output to the speaker.

 instalation:
    clone this repo 
    download your model here ==> https://alphacephei.com/vosk/models  
    install python lib via pip:
        - vosk
        - souddevice
        - paho-mqtt
    put your downloaded model in the folder 'model' without subfolder

usage:
 first run:
    run run.py
    speak your desired wakeword multiple time to see how it's interpreted (check python output) and take note of the output.
        exemple: when i say "eve" sometime the prog understand "euh" or "aise" so i need to add this 3 word as wakeword in myinterpreter.py

    edit myinterpreter.py with your wakeword 
    count the number of letter for each one, the prog will send to ha only the message after wakeword
        exemple:             

            """
            if data.find('eve') == 0 or data.find('euh') == 0 or data.find('aise') == 0:
        
                if data.find('eve') == 0:               
                    data2 = data[3:]
                elif data.find('aise') == 0:
                    data2 = data[4:]
                elif data.find('euh') == 0:
                    data2 = data[3:]
            """
    edit myinterpreter.py to reflect your install ( mqtt broker ip,wakeword, mqtt topic ...)
    

    home assitant part:
        use an automation tha will redirect the question (mqtt) to assist with ollama ==>  "mqtttoollama.yaml"
        use an automation tha will redirect the question (mqtt) to assist without ollama ==>  "mqtttoassist.yaml"
        with this ypu don't need to expose entity to ollama.
        use an automation that will redirect the response to your media_player_entity_id ==>  "ollamaspeak.yaml"
        (don't forget to change the  media_player_entity_id)

it’s very easy to install and use but feel free to ask question if needed.
have fun

Cool, but why not use Whisper?

this is cool, just want to get a custom voice on home assistant, like i try to make the home feel funny, if you use google tts korean voice it sound like 95% of anime :slight_smile:

can you use whisper on your windows computer? i made this because i don’t have hardware like raspberry or homeassistant pe. i have my server behind my couch so an lxc and a usb micro and i can control my home. you can run this script on everything that can run python( windows linux vm lxc amd64/arm64)
it’s almost universal and from my test the wakeword recognition is far better than an esp32. i made this long time ago to control a robot so you can use it for other task, just need to edit myinterpreter.py.

Yes Whisper ships as a container as faster-whisper under the wyoming github org.

I didn’t know but to be honest i don’t really like docker, i use it in last resort

No one likes Docker :hugs:

2 Likes