Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Expected expression (Python, Visual Studio Code)

import speech_recognition as sr
for index, name in enumerate:(sr.Microphone.list_microphone_names()):
print("Microphone with name \"{1}\" found for `Microphone(device_index={0})`".format(index.name))
Expected expression Pylance (Ln 2, Col 70) (View screenshot (https://ibb.co/6sqffmj)) 
and SyntaxError: invalid syntax

Please, help me! (I use a translator, if there are any mistakes, I apologize)

(View screenshot (https://ibb.co/6sqffmj))

I tried copying:
print("A microphone named "{1}" was found for Microphone(device_index={0})".format(index.name)))
and paste it in:
for index, name in enumerate:(sr.Microphone.list_microphone_names()):
but it doesn’t work

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try to use the code bellow:

import speech_recognition as sr

for index, name in enumerate(sr.Microphone.list_microphone_names()):
    print(f"Microphone with name {name} found for Microphone {index}")

In this example, I removed the excessive double quotes that were in the print function, and added the correct identation to the code. I also used the variables index and name in the most correct way. Let me know if the code works for you.

Best reguards.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading