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
  1. Type your text in the input box.
  2. Select a language from the dropdown.
  3. Click Play to generate and hear the audio.
  4. Click Reset to clear the text.
  5. Click Exit to close the app.

How It Works

  1. The text is passed to gTTS(text, lang=lang, tld=tld, slow=False) which calls the Google TTS API.
  2. The audio is saved to output.mp3 in the working directory.
  3. pygame.mixer loads and plays the file.
  4. 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.mp3 file 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 tld parameter (for example co.uk for UK English or com.br for Brazilian Portuguese).

Read all Python Projects and Code Examples guides online · Project overview · All developer projects