📘 Lesson  ·  Lesson 96

Text to Speech

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 CodeKaFunda")
engine.runAndWait()

Using gTTS (saves MP3)

Python
from gtts import gTTS
tts = gTTS("Hello from CodeKaFunda")
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.

इस Project के बारे में

💡 एक नज़र में

Python text को बोली में बदल सकता है pyttsx3 (offline) या gTTS (Google, online) जैसी libraries से।

pyttsx3 (offline)

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

gTTS (MP3 save करता है)

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

सारांश

  • pyttsx3 offline text बोलता है; gTTS Google से MP3 बनाता है।
  • pip install pyttsx3 gTTS से install करें।
← Back to Python Tutorial
🔗

Share this topic with a friend

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

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

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

\n