Convert Text to Speech in Python (original) (raw)

Last Updated : 23 Feb, 2026

Text-to-Speech (TTS) means converting written text into spoken audio. In Python, one of the simplest libraries for this task is gTTS (Google Text-to-Speech).

**Features of gTTS

Installation

To install the gTTS library, open the terminal or command prompt and run:

pip install gTTS

Syntax

The basic syntax for gTTS is:

from gtts import gTTS
myobj = gTTS(text="Your text here", lang="en", slow=False)
myobj.save("output.mp3")

**Parameters:

**Example: This program converts text into speech, saves it as an MP3 file, and plays it using your system's default audio player.

Python `

from gtts import gTTS import os

mytext = 'Welcome to GeeksforGeeks Joe!' language = 'en'

myobj = gTTS(text=mytext, lang=language, slow=False) myobj.save("welcome.mp3") os.system("start welcome.mp3")

`

**Output

**Explanation: