forked from sourabhjagtap95/AwesomePythonScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
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 sourabhjagtap95#41 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
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.
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() | ||
|
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() |
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 |