📘 Lesson  ·  Lesson 96

Text to Speech

About this Project

💡 At a Glance

Python can convert text into spoken audio using libraries like pyttsx3 (offline) or gTTS (Google, online).

Using pyttsx3 (offline)

Python
import pyttsx3
engine = pyttsx3.init()
engine.say("Hello, welcome to CodingEasily")
engine.runAndWait()

Using gTTS (saves MP3)

Python
from gtts import gTTS
tts = gTTS("Hello from CodingEasily")
tts.save("hello.mp3")
print("Audio saved as hello.mp3")
Audio saved as hello.mp3

Summary

  • pyttsx3 speaks text aloud offline; gTTS creates an MP3 using Google.
  • Install with pip install pyttsx3 gTTS.
← Back to Python Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 Live Code Editor

This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.