Text to Speech Desktop App in Python — gTTS and customtkinter (15 Accents)
A Python desktop GUI that converts typed text to speech using Google Text-to-Speech (gTTS), with 15 language and accent options, a modern customtkinter interface, and playback through pygame.
Overview
Text2Audio provides a clean, dark-themed desktop interface where you type text, select a language variant, and press Play to hear the text read aloud. The audio is generated by gTTS and played back using pygame. The app is built with customtkinter for a modern look.
Features
- Text input area for entering any text to convert
- Language selection dropdown with 15 locale options
- Play button that generates and immediately plays the audio
- Reset button to clear the text input
- Exit button to close the application
- Dark mode with blue color theme
- Fixed window size (500×420), centered on screen
- Warning dialogs for empty text or invalid language selection
Supported Languages
| Language | Variant |
|---|---|
| English | Australia, UK, USA, Canada, India, Ireland, South Africa, Nigeria |
| French | Canada, France |
| Portuguese | Brazil, Portugal |
| Spanish | Mexico, Spain, USA |
Requirements
customtkinter
gtts
pygame
Install dependencies:
pip install customtkinter gtts pygame
Usage
From the Text2Audio folder:
python GUI_Code/main.py
- Type your text in the input box.
- Select a language from the dropdown.
- Click Play to generate and hear the audio.
- Click Reset to clear the text.
- Click Exit to close the app.
How It Works
- The text is passed to
gTTS(text, lang=lang, tld=tld, slow=False)which calls the Google TTS API. - The audio is saved to
output.mp3in the working directory. pygame.mixerloads and plays the file.- The app waits for playback to finish before returning control.
File Structure
Text2Audio/
└── GUI_Code/
├── main.py # Entry point — creates and runs TextToAudio instance
└── screen.py # TextToAudio class — UI layout and audio logic
Notes
- An active internet connection is required since gTTS sends requests to Google’s TTS API.
- The generated
output.mp3file is saved in the current working directory and overwritten on each use. - Accents are produced by sending the request to a regional Google domain through gTTS’s
tldparameter (for exampleco.ukfor UK English orcom.brfor Brazilian Portuguese).
Related Projects
- Story Reader — read a PDF aloud with offline TTS
- Setup Wizard — Fruit Wiki GUI
- Back to all Python projects
Documentation links
Read all Python Projects and Code Examples guides online · Project overview · All developer projects