Skip to content

Commit c47ff53

Browse files
authored
Python Program audio to text format (#10)
1 parent a945e9d commit c47ff53

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Speech to Text/speechToText.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# import the module for speech recognition
2+
import speech_recognition as sr
3+
4+
# create the recognizer
5+
u = sr.Recognizer()
6+
7+
# define the microphone
8+
mic = sr.Microphone(device_index=0)
9+
10+
# record your speech
11+
with mic as source:
12+
audio = u.listen(source)
13+
14+
# speech recognition
15+
result = u.recognize_google(audio)
16+
17+
# export the result output
18+
with open('my_result.txt',mode ='w') as file:
19+
file.write("Recognized text:")
20+
file.write("\n")
21+
file.write(result) print("Exporting process completed!")

0 commit comments

Comments
 (0)