dnnsdunca commited on
Commit
a8bc02a
·
verified ·
1 Parent(s): 72498a5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ app_py_content = """
2
+ import speech_recognition as sr
3
+
4
+ def main():
5
+ # Initialize recognizer class (for recognizing the speech)
6
+ r = sr.Recognizer()
7
+
8
+ # Using the microphone.
9
+ with sr.Microphone() as source:
10
+ print("Say something!")
11
+ audio = r.listen(source)
12
+
13
+ try:
14
+ # Using Google's speech recognition
15
+ text = r.recognize_google(audio)
16
+ print("You said: {}".format(text))
17
+ except sr.UnknownValueError:
18
+ print("Google Speech Recognition could not understand audio")
19
+ except sr.RequestError as e:
20
+ print("Could not request results from Google Speech Recognition service; {0}".format(e))
21
+
22
+ if __name__ == "__main__":
23
+ main()
24
+ """
25
+
26
+ # Provide instructions for the user to manually create the file
27
+ 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."
28
+
29
+ app_py_content, instructions