File tree 2 files changed +10
-5
lines changed
2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
# Import the platform module to identify your OS
2
2
import platform
3
+
3
4
# If you are using Windows, use pyttsx3 for text to speech
4
5
if platform .system () == "Windows" :
5
6
import pyttsx3
7
+
6
8
try :
7
9
engine = pyttsx3 .init ()
8
10
except ImportError :
@@ -19,11 +21,12 @@ def print_say(txt):
19
21
engine .say (txt )
20
22
engine .runAndWait ()
21
23
# If you are using Mac or Linux, use gtts for text to speech
22
- if platform .system () == "Darwin" or platform .system () == "Linux" :
24
+ elif platform .system () == "Darwin" or platform .system () == "Linux" :
23
25
import os
24
26
25
27
def print_say (texts ):
26
28
print (texts )
27
- texts = texts .replace ('"' ,'' )
28
- texts = texts .replace ("'" ,"" )
29
- os .system (f'gtts-cli --nocheck "{ texts } " | mpg123 -q -' )
29
+ texts = texts .replace ('"' , '' )
30
+ texts = texts .replace ("'" , "" )
31
+ os .system (f'gtts-cli --nocheck "{ texts } " | mpg123 -q -' )
32
+ # End of File
Original file line number Diff line number Diff line change 1
1
import speech_recognition as sr
2
+
2
3
speech = sr .Recognizer ()
3
4
4
5
@@ -15,4 +16,5 @@ def voice_to_text():
15
16
pass
16
17
except sr .WaitTimeoutError :
17
18
pass
18
- return voice_input
19
+ return voice_input
20
+ # End of File.
You can’t perform that action at this time.
0 commit comments