All
- Hello world in python
- How to add two numbers in python
- If else statement python
- Lists tuples and dictionaries
- Loops in python
- Python Functions
- How To Reverse Number In Python
- How to create voice from words and How to play music in Python
- How to Sort Dictionary using keys or values python
- Python Lambda
- Python map() filter() and reduce() functions
- What does if __name__ == "__main__": do?
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 tts.save('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
playsound('filename.mp3')
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
All
May 7, 2021, 7:20 a.m.
May 23, 2021, 12:19 p.m.
June 21, 2021, 3:08 p.m.
Aug. 26, 2021, 10:22 a.m.