Reputation: 75
I am creating a Python Personal Assistant using Python's Speech Recognition,pyaudio and Python Text to speech modules, so what I want is that after starting the program I want it to say something and have coded it the same, but when I run the program, It starts listening first and until and unless I provide it with any random word it does not move forward. Here is the code for the main function.
import speech_recognition as sr
import random
import functions.Response as speech
import functions.custom_input
import functions.device_stats
import num2words
import sys,os
import functions.check_user
from functions.Response import say,listen
def check():
say("Starting Program")
say("Initializing modules")
say("Modules Intialized")
say("Performing System Checks")
say("Sytem Checks Done")
say("Starting happy protocol")
check()
Any Idea? what to do?
Upvotes: 2
Views: 208
Reputation: 365
Your program is missing a lot of information. This is not a problem because I have been where you are. You are missing some lines of code. Instead of importing things like the say function or response, here is a working and simpler alternative.
import pyttsx3
import speech_recognition as sr
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def say(audio):
engine.say(audio)
engine.runAndWait()
def check():
say("Starting Program")
say("Initializing modules")
say("Modules Intialized")
say("Performing System Checks")
say("Sytem Checks Done")
say("Starting happy protocol")
check()
And you can essentially add commands for your virtual assistant later on...
Upvotes: 2