-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from ozamed/master
Speech To Text & Text To Speech
- Loading branch information
Showing
5 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
Program's_Contributed_By_Contributors/VoiceIO/main/speechInput.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello guys, this is an example. |
Empty file.
22 changes: 22 additions & 0 deletions
22
Program's_Contributed_By_Contributors/VoiceIO/main/voiceInput.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import speech_recognition as sr | ||
|
||
def SpeechRecognition(): | ||
r = sr.Recognizer() | ||
with sr.Microphone() as source: | ||
print('Say something...') | ||
r.pause_threshold = 1 | ||
r.adjust_for_ambient_noise(source, duration=1) | ||
audio = r.listen(source) | ||
try: | ||
outputFile = open("speechOutput.txt","a") | ||
userSpeech = r.recognize_google(audio).lower() | ||
print('You said: ' + userSpeech + '\n') | ||
outputFile.write(userSpeech + '\n') | ||
outputFile.close() | ||
|
||
except sr.UnknownValueError: | ||
print('....') | ||
|
||
while True: | ||
SpeechRecognition() | ||
|
8 changes: 8 additions & 0 deletions
8
Program's_Contributed_By_Contributors/VoiceIO/main/voiceOutput.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import pyttsx3 | ||
|
||
engine = pyttsx3.init() | ||
|
||
inputFile = open("speechInput.txt","r") | ||
|
||
engine.say(inputFile.read()) | ||
engine.runAndWait() |
2 changes: 2 additions & 0 deletions
2
Program's_Contributed_By_Contributors/VoiceIO/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pyttsx3==2.87 | ||
SpeechRecognition==3.8.1 |