@kyle Just out of curiosity, did the computer told you the time, and after telling the time, did it repeat something like “Please say the command again”, continiously, without listening to your voice? As I have faced this issue, when I have declared the command variable, inside and outside the try block.
Hey don’t worry I’ve checked all the necessary libs are there… yeah it will say that sometimes but will be waiting for your command… I thought we took care of the unbound local variable… nywy let’s break the code and start small… the problem is the ability to recognize voice… so open a new python file paste and run tthis…
import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
import wikipedia
import pyjokes
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id) # to change the voice either use zero or one
with sr.Microphone() as source:
print('listening...')
# talk('How can I help you?')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
print(command)
just run this the way it is don’t add or remove anything… be audible enough… even shout lol… this should print whatever the engine has heard… and let me know
Hey yeah it can tell you the time even playing a song and sometimes will repeat the command again but not continuously just once to wait for your other instruction
@kyle The script that you sent, work absolutely fine, no issues at all. It writes what I spoke.
I don’t know why is it working fine for you, and continiously repeating the else statement for me?
awesome… so now voice recognition is great… now its the continuous annoying repetition of the else statement… aha so now the share the whole code so I look into it or better yet try this GitHub - michael305y/alexa_assistant: program to show case Alexa assistant in Python
if you know github then just git clone otherwise just copy the whole code and paste and let me know if there is a difference
Oh my god, tell me what you want in excahnge of this I was working on this for more than 3 weeks, and now I was hopeless. I was rhinking of getting dropped out if the college, as this was part of the project. I am sooo grateful that you helped me as I was your brother. It works, without any errors, and the best part is that it is listening, without any interreption or errors. I will now analyse your code and mine code, and see what i have done wrong, sk I can help others or help myself, in the future. Just tell me what you want, so I can thank you. You are life saver and a permanent hero for me.![]()
![]()
![]()
Hey Danish, I want a landrover defender lol… but for real don’t worry it’s all good am glad you are soughted. Lol I understand programming is challenging and frustrating actually most of the times…Aha so one tip with projects is to break the project into smaller chunks like for this you just start with is alexa listening, if its listening what can i do next, now you start thinking if it can write what it heard and if it can write then it can talk and now you start looking for how it would talk etc…
S yeah the ability to troubleshoot is the best superpower one can have coz most of the time it doesn’t work. So yeah troubleshooting, resilience and asking without embarassment can save you alot of time and forums usually have guys that have a solution at hand… cheers.
Absolutely right, the process of breaking things down is called “Decomposition” and is part of the 4 stepping stone of the computational thinking. Due to the prrssure of the bug, I couldn’t think straight. Thank you soo much for your extreme help and kindness, I hope that all of the humans are like you, kind and life savers.
