Many methods are available for Text to speech conversion here we discuss how we can convert any text to speech using python by importing win32com.client for windows.

import win32com.client as wincl
speak = wincl.Dispatch("SAPI.SpVoice")
speak.Speak("God is Great")

To convert text to speech and save as audio file(mp3) we can also use gtts(google text to speech) module.

First we need to install gtts module using pip

pip install gTTS
#import gtts module
import gtts
test = gtts.gTTS("God is great")
test.save(test.mp3)

MP3 file will be saved in current directory. You can also change language by writing below code.

ob = gtts.gTTS(text="kaise hai aap",lang='hi')  
ob.save('testhindi.mp3')

By SC

Leave a Reply

Your email address will not be published. Required fields are marked *