

If you don't want to save it to a file and just play it directly, then you should use tts.write_to_fp() which accepts io.BytesIO() object to write into, check this link for more information. It isn't available only in English, you can use other languages as well by passing the lang parameter: # in spanish Up to this point, we have sent the text and retrieved the actual audio speech from the API, let's save this audio to a file: # save the audio fileĪwesome, you'll see a new file appear in the current directory, let's play it using playsound module installed previously: # play the audio fileĪnd that's it! You'll hear a robot talking about what you just told him to say! It's pretty straightforward to use this library, you just need to pass text to the gTTS object that is an interface to Google Translate's Text to Speech API: # make request to google to get synthesis Open up a new Python file and import: import gtts It requires an Internet connection and it's pretty easy to use.
#Text to wav converter install
To get started, let's install the required modules: pip3 install gTTS pyttsx3 playsound Online Text to SpeechĪs you may guess, gTTS stands for Google Text To Speech, it is a Python library to interface with Google Translate's text to speech API. To make things clear, this tutorial is about converting text to speech and not the other way around, if you want to convert speech to text instead, check this tutorial.
#Text to wav converter Offline
There are a lot of APIs out there that offer this service, one of the commonly used services is Google Text to Speech, in this tutorial, we will play around with it along with another offline library called pyttsx3. Instead, we gonna use some APIs and engines that offer it. In this tutorial, we won't be building neural networks and training the model in order to achieve results, as it is pretty complex and hard to do it. In this tutorial, you will learn how you can convert text to speech in Python. It converts human language text into human-like speech audio. Speech synthesis (or Text to Speech) is the computer-generated simulation of human speech.
