mobileai / app.py
dnnsdunca's picture
Create app.py
a8bc02a verified
app_py_content = """
import speech_recognition as sr
def main():
# Initialize recognizer class (for recognizing the speech)
r = sr.Recognizer()
# Using the microphone.
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
try:
# Using Google's speech recognition
text = r.recognize_google(audio)
print("You said: {}".format(text))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
if __name__ == "__main__":
main()
"""
# Provide instructions for the user to manually create the file
instructions = "Copy the above Python code into a new file named app.py using a text editor or IDE like VS Code. Save the file in your project directory. Then, you can run it with the command `python app.py` in your terminal or command prompt."
app_py_content, instructions