Joke App is a fun application that fetches jokes from an API and displays them on a GUI. It supports two types of jokes: single-part and two-part jokes. The app also reads the jokes aloud using a text-to-speech (TTS) library. For two-part jokes, the app switches between different accents for each part. At the end of each joke, the app fetches and displays a random laughing GIF from an API. The TTS functionality is handled with timers and threading to ensure smooth and real-time playback.
- Two Types of Jokes: Fetches and displays single-part or two-part jokes.
- Text-to-Speech (TTS): Reads jokes aloud, using different accents for two-part jokes.
- GIF Integration: Displays a random laughing GIF after the joke, fetched from the Giphy API.
- Accents: TTS supports 5 accents: American, Australian, British, Canadian, and Indian.
- Real-time Audio and Visual Sync: The joke is read aloud in sync with the text on the screen using threading and a timer mechanism.
This is the main GUI file of the application. It handles:
- Displaying the joke on the screen.
- Showing the random GIF after the joke.
- A button labeled "Tell me a joke!" that fetches a new joke and reads it aloud.
Handles the API call to Giphy. It fetches a random laughing GIF using a keyword ("laughing") from the Giphy API. You will need to generate an API key from the Giphy website to use this.
This file handles the text-to-speech conversion. It:
- Select a random accent from 5 predefined accents (American, Australian, British, Canadian, Indian).
- Converts the joke text to an MP3 file.
- Plays the MP3 file and deletes it after playback.
Fetches a random joke from the open-source JokeAPI. This API provides both single-part and two-part jokes.
To install the required libraries, run:
pip install -r requirements.txt
-
Clone the repository:
git clone https://github.com/dheerajkallakuri/JokeApp.git
-
Navigate to the project directory:
cd JokeApp
-
Run the app:
python app.py
-
Click the Tell me a joke! button to fetch, display, and hear a random joke, along with a laughing GIF.
This app demonstrates how to handle:
- Multiple API calls (for jokes and GIFs).
- Synchronizing text-to-speech with the visual display of the joke.
- Managing TTS conversion with multiple accents.
- Threading and timers are used to ensure seamless synchronization between audio playback and the text displayed on the screen.