-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathspeech2text.py
More file actions
25 lines (19 loc) · 874 Bytes
/
Copy pathspeech2text.py
File metadata and controls
25 lines (19 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import speech_recognition as sr # Speech Recognition
import pyttsx3 # Conversion of Text to Speech
import config # Importing input and output directory paths
import audioengine
# define the microphone
print("Converting speech to text".center(400))
audioengine.speak("Converting speech to text")
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
print("Please start speaking....") # record your speech
audioengine.speak("Please start speaking")
result = r.recognize_google(audio, language='en-us') # speech recognition
print("Recording Stopped")
print("Converting to Text File")
with open(config.outputpath+"speechtotext.txt", mode='w') as file: # export the result
file.write(result)
print("Your file has been converted successfully!".center(400))
audioengine.speak("Your file has been converted successfully!")