#๐Ÿ”’ Coding help

78 messages ยท Page 1 of 1 (latest)

next ermineBOT
#

@maiden cave

Python help channel opened

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.

maiden cave
#

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

carmine wraith
maiden cave
#

ye so i will say Jarvis open youtube

#

so i can execute open youtube by saying jarvis first

carmine wraith
#

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

maiden cave
#

damn my smol and stupid brain is being fried XD

maiden cave
modest eagle
#

ok so you want your jarvis to open youtube right ?

modest eagle
#

then you must be using SpeechRecognition library right ?

maiden cave
#

the Ai also doesnt work when i aks something it doesnt reply anthing back to me xD

modest eagle
#

then just elif "open youtube in said":
webbrowser.open("youtube.com")

maiden cave
#

yey it worked xD

modest eagle
maiden cave
modest eagle
#

sure go ahead

maiden cave
#

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

maiden cave
maiden cave
modest eagle
#

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")
maiden cave
#

oh

modest eagle
#

wait i need to look more

maiden cave
#

there

modest eagle
#

what are you trying to do with this code

maiden cave
#

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

modest eagle
modest eagle
maiden cave
#

im learning because i always encounter problem and always have to solve it into 2-3 days xD

modest eagle
#

ok dont worry give me a minute

maiden cave
#

alr thank you ๐Ÿ˜„

modest eagle
#

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

maiden cave
#

ohh

#

alr

modest eagle
#

also write jarvis instead of Jarvis

#

and then try

maiden cave
#

the ai?

#

the youtube works now

modest eagle
maiden cave
#

the code works

#

but when i ask the ai

#

it doesntrespond to me

modest eagle
#
                    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)```
next ermineBOT
#

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.
modest eagle
#

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

modest eagle
#

i would suggest learning basics of python and start by making smaller projects and then moving to more complex one

modest eagle
maiden cave
#

oh so it wont work anymore?

modest eagle
#

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

maiden cave
#

ohh

modest eagle
#

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

maiden cave
#

hmm alr thank you

next ermineBOT
#
Python help channel closed

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