Skip to content

Commit 5090465

Browse files
committed
feat: Added speech to text program
1 parent 72f02fb commit 5090465

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Speech To Text/main.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import speech_recognition
2+
3+
def record_voice():
4+
microphone = speech_recognition.Recognizer()
5+
6+
with speech_recognition.Microphone() as live_phone:
7+
microphone.adjust_for_ambient_noise(live_phone)
8+
print("I'm trying to hear you: ")
9+
audio = microphone.listen(live_phone)
10+
try:
11+
phrase = microphone.recognize_google(audio, language='en')
12+
return phrase
13+
except speech_recognition.UnkownValueError:
14+
return "I didn't understand what you said"
15+
16+
if __name__ == '__main__':
17+
phrase = record_voice()
18+
19+
with open('you_said_this.txt','w') as file:
20+
file.write(phrase)
21+
22+
print('The last sentence you spoke was saved in you_said_this.txt')

0 commit comments

Comments
 (0)