Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit f997d5e

Browse files
authored
Merge pull request #123 from pauloSantosLuz/feature/speech-to-text
speech_to_text done
2 parents 878896d + 2fc3b96 commit f997d5e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PyAudio==0.2.11
2+
SpeechRecognition==3.8.1
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
9+
print("I'm trying to hear you: ")
10+
audio = microphone.listen(live_phone)
11+
try:
12+
phrase = microphone.recognize_google(audio, language='en')
13+
return phrase
14+
except speech_recognition.UnkownValueError:
15+
return "I didn't understand what you said"
16+
17+
if __name__ == '__main__':
18+
phrase = record_voice()
19+
20+
with open('you_said_this.txt','w') as file:
21+
file.write(phrase)
22+
23+
print('the last sentence you spoke was saved in you_said_this.txt')

0 commit comments

Comments
 (0)