#๐ Coding help
78 messages ยท Page 1 of 1 (latest)
@maiden cave
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
in this code
when i said Jarvis open Youtube
it wont open youtube it just stays on listen
also its my first time using pycharm and learning python
it checks the conditions from top to bottom. And it finds the Jarvis condition first, therefore is never reaching the open youtube one
ye so i will say Jarvis open youtube
so i can execute open youtube by saying jarvis first
if you say Jarvis open youtube you will go into this branch:
elif "Jarvis" in said:
new_string = said.replace("Jarvis", "").strip()
print(new_string)
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": new_string}]
)
text = completion.choices[0].message.content
play_audio(text)
you never reach the one where it checks for youtube
damn my smol and stupid brain is being fried XD
can you tell me step by step on how to do it? if you dont want its fine :DD
ok so you want your jarvis to open youtube right ?
yes sir
then you must be using SpeechRecognition library right ?
yes
the Ai also doesnt work when i aks something it doesnt reply anthing back to me xD
then just elif "open youtube in said":
webbrowser.open("youtube.com")
wait ill put it in rn
yey it worked xD
๐
one more problem
sure go ahead
so i put the api key for open ai so when i ask a question it would answer me but whei ask it it doesnt respond
@maiden cave qestion
also this code is from youtube just tryng to enchance it
whos
i forgot the guy name but i watch the whole video while he was oding
share the code
should i give the Api key also?
no no need
elif "Jarvis" in said:
new_string = said.replace("Jarvis", "").strip()
print(new_string)
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": new_string}]
)
text = completion.choices[0].message.content
play_audio(text)
elif "open YouTube" in said:
print("Recognized 'open YouTube' command")
play_audio("Opening YouTube")
subprocess.Popen(["start", "https://www.youtube.com"], shell=True)
print("YouTube should be open now")
oh
wait i need to look more
what are you trying to do with this code
trying to make an ai
that i can ask
sorry im just new
i dont really know anything
i just go into stackoverflow
to learn the problem i encounter
nothing to sorry about you wont but i too created such program with a lot of if else statements ๐ ๐
just learn the basics and get familiar with understanding documentation
im learning because i always encounter problem and always have to solve it into 2-3 days xD
ok dont worry give me a minute
alr thank you ๐
elif "open YouTube" in said:
print("Recognized 'open YouTube' command")
play_audio("Opening YouTube")
subprocess.Popen(["start", "https://www.youtube.com"], shell=True)
print("YouTube should be open now")
remove this
its case sensitive so it wont work
and it not necessary to use Popen to open a website
the ai is not working ?
print(new_string)
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": new_string}]
)
text = completion.choices[0].message.content
play_audio(text)```
Hey @modest eagle!
It looks like you pasted Python code without syntax highlighting.
Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
the code above wont work
because new_string = said.replace("Jarvis", "").strip() this line actually takes the string Jarvis and makes it empty and then striping it wont give you anything except an empty string
i would suggest learning basics of python and start by making smaller projects and then moving to more complex one
yes
oh so it wont work anymore?
no no i am not saying it wont work it will but once you have a grip over logic building then you will be able to get the feel of writing code
ohh
break down a task into sub-task and try to write then sequentially
try making diagrams in your head and then convert it into code
hmm alr thank you
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ Coding help