Text-to-Speech Dictionary Application Overview

Description

This web page provides an overview of a Python-based dictionary application that features text-to-speech functionality. The application allows users to enter a word, search for its definition, and hear the pronunciation through computer speech output.

Text-to-Speech Dictionary

How It Works

The application uses several libraries to create a GUI, fetch definitions from a dictionary API, and convert text to speech:

Application Flow

  1. User enters a word into the input field and clicks the 'Search' button.
  2. An HTTP GET request is made to the dictionary API using the requests library to retrieve the definition.
  3. If found, the definition is displayed in the GUI, and gTTS synthesizes the speech from the definition text.
  4. The speech is played back to the user using pygame's mixer module.

Code Snippet


    # Fetch and display definition
    if event == 'Search':
        word = values['WORD']
        response = requests.get(f"https://api.dictionaryapi.dev/api/v2/entries/en/{word}")
        ...
    
    # Convert definition to speech and play
    tts = gTTS(text=definitions, lang='en')
    ...
    pygame.mixer.music.play()
        

Requirements

To run this application, ensure that you have installed the following Python libraries:

These can be installed using pip:

pip install PySimpleGUI gTTS requests pygame