Commit 97e16702 authored by Adam Blank's avatar Adam Blank
Browse files

Update util.py

No related merge requests found
Showing with 12 additions and 5 deletions
+12 -5
from gtts import gTTS
import playsound
from pyt2s.services import stream_elements
from pydub import AudioSegment
from pydub.playback import play as p
import io
def play(script):
tts = gTTS(text=script, lang='en')
tts.save("sound.mp3")
playsound.playsound("sound.mp3")
play_with_voice(script, "Amy")
def play_with_voice(script, voice):
data = stream_elements.requestTTS(script, voice)
song = AudioSegment.from_file(io.BytesIO(data), format="mp3")
p(song)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment