Search your course



How to create voice from words and How to play music in Python


First let see that how to create .mp3 file from string, type any thing in as a string and python gtts module will convert it into sound file.First install gtts through pip then execute following lines of code


from gtts import gTTS
tts=gTTS(text='Put your text here',lang='en')#language English'filename.mp3')


Now lets see how to play music using python, for that , use playsound library

install playsound using

pip install playsound

then run following code


from playsound import playsound


If file is not present in directory where code file exists then provide complete path and then place then file name e.g E:\New Folder\File.mp3


Subscribe to my youtube channel