A simple text-to-speech program using:
Install Google Text-to-Speech lib
user@linux:~$ pip install gTTSGoogle Text-to-Speech
from gtts import gTTSTo use operating system funcionalities, import Python OS module
import osTkinter Python GUI
from tkinter import *To show errors, attention and other alert messages
from tkinter import messageboxFor Mac OS users, some buttons and icons does not work properly. Please, use ttk submodule.
from tkinter import ttkBefore running the program, you need to choose the correct player based on your operating system.
(afplay is a Mac OS command.)
- For Arch Linux based (Manjaro...)
user@linux:~$ sudo pacman -S mpg123- For Debian Linux based (Ubuntu...)
user@linux:~$ sudo apt-get update
user@linux:~$ sudo apt-get install mpg123- For Redhat Linux based (Fedora, SUSE...)
user@linux:~$ yum install mpg123- For Windows mpg123 for Windows
After successful installation, you can test it.
user@linux:~$ mpg123 <some_audio_file>.mp3It's necessary to change afplay to correct mp3 player at /source/TextToSpeech.py
#The argument & indicates afplay to run in the background as a job.
os.system("afplay sound/output.mp3 &")This project is licensed under the MIT License.
