Python Script for Asynchronous Voice Assistant

Job ID: 37813089

Budget: $10 – $30 USD

I created a simple, 500 line voice assistant that uses gpt 3.5. The user can say "Jarvis" as the wake word, and the script will listen for a command, whatever is spoken next is sent to the gpt 3.5 api, and the response is spoken out loud.

The script works perfectly, except I'm having difficulty getting it to work asynchronously and allow interrupting the ai during the response. I tried splitting the AI's response into multiple sentences, and checking between each sentence if the wake word has been spoken, but if for example I say "Jarvis" and then "Jarvis" again a few seconds later, the AI will finish the entire response, and then will recognize that I said Jarvis, and will recognize it again a few seconds later.

So the program is successfully hearing the response, but not interrupting the text to speech playback.

Someone suggested that I use asyncio, but Python is not my best language, so I'm hoping someone else can solve this.

I'm creating the voice assistant as a gift for my dad's birthday which is the day after tomorrow, if you're able to help, please include the word "picture frame" in your bid so I know you read the description and can complete the project for the amount bid.

This is the code I'm using, I removed my porcupine access key, and my openai key. You will also need google cloud credentials since I'm using Google's text to speech, but I'm open to using other solutions if you want to replace it, as long as it's a natural sounding tts solution like xtts.

https://pastebin.com/hba7UY2G
Related categories: Python Voice Assistance Devices