Spaces:
Sleeping
Sleeping
Commit
·
fe3eb8e
1
Parent(s):
180cca3
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,8 @@ import pyttsx3
|
|
8 |
import time
|
9 |
import os
|
10 |
import subprocess
|
11 |
-
|
|
|
12 |
|
13 |
|
14 |
aws_key_id = os.environ['aws_access_key_id']
|
@@ -43,32 +44,9 @@ except (BotoCoreError, ClientError) as error:
|
|
43 |
|
44 |
|
45 |
def speak_text(text):
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
# This module is imported so that we can
|
51 |
-
# play the converted audio
|
52 |
-
import os
|
53 |
-
|
54 |
-
# The text that you want to convert to audio
|
55 |
-
mytext = text
|
56 |
-
|
57 |
-
# Language in which you want to convert
|
58 |
-
language = 'en'
|
59 |
-
|
60 |
-
# Passing the text and language to the engine,
|
61 |
-
# here we have marked slow=False. Which tells
|
62 |
-
# the module that the converted audio should
|
63 |
-
# have a high speed
|
64 |
-
myobj = gTTS(text=mytext, lang=language, slow=False)
|
65 |
-
|
66 |
-
# Saving the converted audio in a mp3 file named
|
67 |
-
# welcome
|
68 |
-
myobj.save("welcome.mp3")
|
69 |
-
|
70 |
-
# Playing the converted file
|
71 |
-
os.system("mpg321 welcome.mp3")
|
72 |
|
73 |
|
74 |
|
|
|
8 |
import time
|
9 |
import os
|
10 |
import subprocess
|
11 |
+
import gtts
|
12 |
+
from playsound import playsound
|
13 |
|
14 |
|
15 |
aws_key_id = os.environ['aws_access_key_id']
|
|
|
44 |
|
45 |
|
46 |
def speak_text(text):
|
47 |
+
tts = gtts.gTTS(str(text))
|
48 |
+
tts.save("hello.mp3")
|
49 |
+
playsound("hello.mp3")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
|
52 |
|