• Post author:
  • Post category:Technology
  • Post last modified:January 4, 2024
  • Reading time:2 mins read
Home » Technology » Text To Speach Code

This post may contains affiliate links. As an amazon associate I earn from qualifying purchases.

Simple few lines of code for converting text to speach. TTS

Numerous applications offer text-to-speech functionality, but they often come with limitations, such as a restricted word count for free usage. Monthly plans are available, but they might not suit everyone’s preference, especially those seeking a free solution.

https://youtu.be/5shxd8e78JA

As the saying goes, “nothing in life is truly free,” and this holds for many free services that come with restrictions. However, for those willing to delve into the world of Python, there’s a workaround that is both cost-effective and liberating.

This method is particularly beneficial to individuals heavily reliant on text-to-speech conversions, such as content creators crafting faceless videos.

Steps to Unlock Free Text-to-Speech:

  • Brush Up on Basic Python Skills: Start by refreshing your basic Python skills. If you’re new to Python, it’s essential to learn how to download and install Python, set up your development environment, choose a favorite code editor, write code, save the file, and open it.
  • Craft Your Code: The Python code snippet below provides a foundation for your text-to-speech endeavors. Copy and customize it to suit your specific needs, if you can.

pip install gTTS moviepy                              #install gTTS moviepy

from gtts import gTTS
import moviepy.editor as mp

text = ”’Write here text here”’                     #if your text is long, use triple quotes

tts = gTTS(text, lang=’en’)                          #define your vaiable, give it any name.

tts.save(“output.mp3”)           

clip = mp.AudioFileClip(“output.mp3”)  # this will Convert your audio file (mp3) to an MP4 video


This is a basic example using the pyttsx3 library, but there are other libraries and tools available that you can explore based on your requirements.

By using this approach, you not only overcome the limitations imposed by many applications, but also you gain a deeper understanding of the Python language. Empower yourself with the ability to create tailored solutions that align with your unique needs.

This post may contains affiliate links. As an amazon associate I earn from qualifying purchases.