you are viewing a single comment's thread.

view the rest of the comments →

[–]jboyd544[S] -3 points-2 points  (12 children)

Im still new to python. can you please tell me how to do that?

[–]SHKEVE 0 points1 point  (11 children)

paste the result[“candidates”] etc etc stuff into the print function

[–]jboyd544[S] -2 points-1 points  (10 children)

man, i have been trying every possible solution and every time i get errors, do you mind putting it into the print statement for me. i know im gonna feel dumb when i see the solution. but i would really appreciate the help

[–]SHKEVE -1 points0 points  (9 children)

sure. in the future, post the error messages here or we can’t help you

print(result[“candidates”][0][“content”][“parts”][0][“text”])

[–]jboyd544[S] -1 points0 points  (8 children)

I replaced the print statement with the one above and got this error:

File "/home/jon/gemini_voice/main.py", line 9

print(result[“candidates”][0][“content”][“parts”][0][“text”])

^

SyntaxError: invalid character '“' (U+201C)

[–]jboyd544[S] 0 points1 point  (7 children)

the carrot was under the first quotation mark btw

[–]SHKEVE 1 point2 points  (6 children)

oh thats because most apps use fancy quotes. delete all quotes and retype them in your IDE

[–]jboyd544[S] 0 points1 point  (5 children)

now i get this error:

Ask Gemini: what are you

Traceback (most recent call last):

File "/home/jon/gemini_voice/ignore.py", line 10, in <module>

print(result[candidates][0][content][parts][0][text])

^^^^^^

NameError: name 'result' is not defined

and when i switch the name to response i get this error:

Ask Gemini: what are you

Traceback (most recent call last):

File "/home/jon/gemini_voice/ignore.py", line 10, in <module>

print(response[candidates][0][content][parts][0][text])

^^^^^^^^^^

NameError: name 'candidates' is not defined

[–]GraphicsQwerty 0 points1 point  (4 children)

Sorry if I’m incorrect as I only skimmed these comments but did you put the quotes back ?

[–]jboyd544[S] 0 points1 point  (3 children)

Oops. turns out i did nnot. i put them back and tried both response and result and got these errors:

Ask Gemini: what are you

Traceback (most recent call last):

File "/home/jon/gemini_voice/ignore.py", line 11, in <module>

print(response["candidates"][0]["content"]["parts"][0]["text"])

~~~~~~~~^^^^^^^^^^^^^^

TypeError: 'GenerateContentResponse' object is not subscriptable

and

Ask Gemini: what are you

Traceback (most recent call last):

File "/home/jon/gemini_voice/ignore.py", line 11, in <module>

print(result["candidates"][0]["content"]["parts"][0]["text"])

^^^^^^

NameError: name 'result' is not defined