From 1c6bfd356bc4561bf6ed72bfa0228ecc711c09b0 Mon Sep 17 00:00:00 2001 From: SAUMITRAJAGDALE Date: Fri, 2 Oct 2020 10:14:55 +0530 Subject: [PATCH] added a script using google text to speech conversion --- text_to_audio.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 text_to_audio.py diff --git a/text_to_audio.py b/text_to_audio.py new file mode 100644 index 0000000..052889c --- /dev/null +++ b/text_to_audio.py @@ -0,0 +1,19 @@ + +from gtts import gTTS +import os + +# Enter the text in string format which you want to convert to audio +mytext = "Hello World!, this audio is created using GTTS module." + +# Specify the language in which you want your audio +language = 'en' + +# Create an instance of gTTS class +myobj = gTTS(text=mytext, lang=language, slow=False) + +# Method to create your audio file in mp3 format +myobj.save("hello_world.mp3") +print("Audio Saved") + +# This will play your audio file +os.system("mpg321 welcome.mp3")