Best FREE AI based Text To Speech python code

ttsmms

Text-to-Speech with The Massively Multilingual Speech (MMS) Project View github repository

Supported Languages

Scaling Speech Technology to 1000+ languages. View all supported languages

Steps to Run on Local System:

Step 1: Choose a folder and open Command Prompt (CMD) inside that folder. Once opened, type the following commands:

python -m venv venv
venv\Scripts\activate

Now, you will see (venv) inside your command prompt.

In this CMD, type the following commands to install the required packages:

pip install ttsmms
pip install ipython

Step 2: Create a file named download.py and add the following code in it:

from ttsmms import download
dir_path = download("hin","./data") # lang_code, dir for save model

Step 3: Run the above file in the terminal using the following command:

python download.py

This command will download and install the model for the specified language code.

Step 4: Create a file named main.py and add the following code in it:

from ttsmms import TTS
from IPython.display import Audio

tts=TTS("./data/eng") 
text = """ hello guys welcome back to our channel """
wav_text =tts.synthesis(text)
wav=tts.synthesis(text)

Audio(wav_text["x"], rate=wav["sampling_rate"])

tts.synthesis(text,wav_path="test.wav")

Step 5: Run the above file in the terminal using the following command:

python main.py

This command will create a .wav audio file for the text you entered in the code.