Why am I even Writing this Article? Well, It hasn’t been a long since I joined . And I have been seeing an on the website which is . It’s kinda cool. At least I think it is 🤪. HackerNoon audio file embedded with each article auto-generated So, I thought why not try getting an audio file using Python which is somewhat similar to the one auto generated by HackerNoon for all it’s articles. Kinda learn by doing thing.So, let’s proceed. What are we gonna use? Legends say Python has a plethora of libraries for everything but for this I could find only one in working state. Simply put cause that’s the only library I could put to work. Others are namely ( ) and ( ). pyttsx3 gtts Google text to speech API python-espeak Python C extension for the eSpeak speech synthesizer I wasn’t able to get to work and didn’t even install properly on my system. gtts python-espeak Installation pip install pyttsx3 That’s all it takes to install, Python is beautiful you know? Let’s get started Steps we are gonna follow: import pyttsx3 pass it the required text save the speech as an audio file Getting hands dirty with code Firstly, let’s get the code to output something through the speakers: import pyttsx3 # importing the library engine = pyttsx3.init() # initialising the pyttsx3 engine # setting engine properties engine.setProperty('rate',125) # setting the rate of words per minute text = '''And I have been seeing an audio file embedded with each article on the website which is auto-generated. It’s kinda cool. At least I think it is.''' engine.say(text) # this line queues the text for conversion engine.runAndWait() # this command processes the commands in the queue # the say command outputs the speech via the sound output device Now, let’s save that as an audio file: import pyttsx3 engine = pyttsx3.init() engine.setProperty('rate',125) text = '''And I have been seeing an audio file embedded with each article on the website which is auto-generated. It’s kinda cool. At least I think it is.''' engine.save_to_file(text,'text.mp3') # this command queues the text to be saved as an audio file engine.runAndWait() The above code saves the audio as an file with the name . . .mp3 text Here’s how it sound Now, let’s try to include some female voice: There is included with the core package.The following is for users as they can use (a C library pre-installed on linux). No Female Voice pyttsx3 linux espeak I learnt about this from which also references to this . this stackoverflow question github issue import pyttsx3 engine = pyttsx3.init() engine.setProperty('rate',125) engine.setProperty('voice','english+f3') text = '''And I have been seeing an audio file embedded with each article on the website which is auto-generated. It’s kinda cool. At least I think it is.''' engine.save_to_file(text,'text_female.mp3') engine.runAndWait() Here’s how it sounds. Resources The best resource I can suggest to learn from is the . I taught myself using the same and hail lord Google for it’s quick answers to my problems. pyttsx3 official documentation Conclusion Well, I couldn’t reach any closer to creating the audio files as good in quality as HackerNoon but at least we tried it using our favourite language Python. So, we used for converting text to speech in . We didn’t do much other than using an existing API but it can be used as a tinier application for larger programs if we use our brains right enough for a large scale Python project. See you fellas, later on, it was fun learning all this with you. pyttsx3 Python