A simple Python-based Text-to-Speech (TTS) application using the gTTS
library to convert user-inputted text into speech. This tool is easy to use, supports multiple languages, and allows you to save the generated speech as an audio file.
- Convert text to speech in just a few steps.
- Save the output audio as an
MP3
file. - Supports multiple languages (based on Google TTS).
- Option to choose normal or slow speech playback speed.
Before running the program, ensure you have the following:
-
Python: Version 3.6 or higher. Download it from python.org.
-
Required Libraries: Install the following Python libraries:
pip install gTTS
-
Operating System: The
os.system
command is used to play the audio file. It is tested on Windows. Adjust commands for other operating systems (e.g.,open
for macOS orxdg-open
for Linux).
-
Clone this repository or download the script file.
-
Open your terminal or command prompt.
-
Run the script using the following command:
python text_to_speech.py
-
Follow the on-screen instructions:
- Enter the text you want to convert to speech.
- Specify the language code (default is
en
for English). - Choose whether the playback should be slow or normal.
-
The generated audio will be saved as
output.mp3
in the current directory and played automatically.
- Text:
Hello, welcome to the Text-to-Speech Converter!
- Language Code:
en
- Speed:
no
- Audio saved as
output.mp3
. - The audio will play automatically.
This application supports various languages. Use the corresponding language codes (e.g., en
for English, es
for Spanish, fr
for French). Refer to the Google TTS Documentation for a full list of supported languages and their codes.
- An internet connection is required for
gTTS
to function. - Unsupported language codes will result in an error.
- Audio playback is platform-dependent; adjust the playback command (
os.system
) if necessary.
- Add a graphical user interface (GUI) using
tkinter
. - Support batch processing for multiple text inputs.
- Implement offline TTS using libraries like
pyttsx3
.
This project is licensed under the MIT License. See the LICENSE
file for details.
Contributions are welcome! If you have any suggestions or improvements, feel free to open an issue or submit a pull request.
Nitin
Feel free to connect and share your feedback!