@green carbon
#Speech Recognition module problem
1 messages · Page 1 of 1 (latest)
The problem's with chat() function, for the rest of the operations, text to speech recognition is working, but for chat(), it's not, I have implemented speaker.Speak in both function as well as else block, but the issue still remains
Do you get an error?
no, the terminal is showing the output, it's just that the speaker.Speak isn't working
What output? Your chat() function isn't printing anything to the terminal?
Oh I see the problem
https://gist.github.com/ZechCodes/2f085eb262f58ee7e40356d587deff19#file-message-txt-L149
Line 149, your if statement is wrong. You can't use or like that
!exec
if "using ai".lower() or "using AI" in "foo":
print("ran")
@lilac cape
✅ Exec - Success (Super User 🦸)
ran
!exec modules | Completed in 0.0159 milliseconds
!exec
if "using ai".lower() in "foo" or "using AI" in "foo":
print("ran")
@lilac cape
✅ Exec - Success (Super User 🦸)
*No output or exceptions*
!exec modules | Completed in 0.0046 milliseconds
elif "Using AI".lower() in query.lower() or "Using Artificial Intelligence".lower() in query.lower():
You need to change line 149 to something like that
what?... there is
There is what?
oh, I didn't copied the print statement from my code, my bad
this block is perfectly working, the problem is with else block
The else block is never running because this block always runs
"Using AI".lower() always evaluates to True
You basically have this...
if True or "Using Artificial Intelligence" in query.lower():
Change it to this and let me know if it works
You've done something similar on line 85 but you've done it correctly there https://gist.github.com/ZechCodes/2f085eb262f58ee7e40356d587deff19#file-message-txt-L85 You need to apply the same principle to line 149
Because if you want to check if multiple things are in something you need to do it like this:
if "foo" in "bar" or "baz" in "bar":
You can't do
if "foo" or "baz" in "bar"
It's getting evaluated like this:
if ("foo") or ("baz" in "bar")
It's just looking at the "foo" on it's own and since a non-empty string is True then that if statement will always be True
Wait..
My elif block with using ai should only work if I am saying a sentence with words using ai, it shouldn't work in any other case
What you had before meant it was running in every case
Now it should work as you expect
No problem