My text to speech program made with python

Hello there, It's me David. I've been dreaming of writing my first hahsnode article and I'm glad I've finally done it. Well, today I'll be walking you through a simple project I did this morning (8/10/2022) on my phone. Yeah my phone!
So yesterday, I received a long ( not so long ) list of things I had to study. I felt so lazy to read through the list and so I had this idea to record it on my phone and listen to it instead.
After I thought about it for a while, i realized that reading and recording it would actually mean that I had read it. As a smart guy, I decided not to and so i slept off. Lol.
Early this morning, I had a brilliant idea to make a program to read through the list and record it as an mp3 file for me. But how would I do that? You guessed it right - with gTTS and Python.
First of all, I thought of the process and outlined the idea as follows:
Copy the list file and save it as a .txt file in the project folder
Read the file with the python file library
from gtts import gTTS
with open('file txt') as f:
list=f.read()
- Assign the file content as the content to be read by gTTS
from gtts import gTTS
with open('file txt') as f:
list=f.read()
tts=gTTS(list, lang='en')
tts.save('sound.mp3')
- Play the sound and enjoy.
This was fun and I spent just 5 minutes doing this. I used my phone and the pydroid 3 app to accomplish this. Not the best project for a portfolio but I'm glad I could solve the problem and also write an article about it. Double win if you ask me. If you'd love to continue working on this project, I've got an idea to make it better. Try adding an instrumental beat to it so that it sounds like actual music. Till we meet again. Thank you for reading.
PS: if you're like me and you do not want to read this. Copy and paste the code and copy this file too. Happy listening.
With Love, David


