Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Text to speech conversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

# Import the required module for text
# to speech conversion

from gtts import gTTS


# This module is imported so that we can
# play the converted audio

import os


# The text that you want to convert to audio

mytext = 'Welcome to python programs!'


# Language in which you want to convert

language = 'en'


# Passing the text and language to the engine,
# here we have marked slow=False. Which tells
# the module that the converted audio should
# have a high speed

myobj = gTTS(text=mytext, lang=language, slow=False)


# Saving the converted audio in a mp3 file named
# welcome

myobj.save("welcome.mp3")


# Playing the converted file

os.system("mpg321 welcome.mp3")