top of page
  • Andrew Jones

Text-To-Speech in 3 lines of Python code

gTTS (Google Text-to-Speech), is a Python library and CLI tool to interface with Google Translate’s text-to-speech API.

Have a read of the docs to get right into the details!

To get you started however, here are 3 lines of code that will take a text string, convert it to speech, and save an mp3 file for you to listen to. (use pip install gTTS to install the package)

from gtts import gTTS

tts = gTTS(text='Hello from analytics-link!', lang='en')"tts_file.mp3")


322 views0 comments

Recent Posts

See All
bottom of page