Skip to content

Built a joke app that displays and reads jokes and GIFs.

Notifications You must be signed in to change notification settings

dheerajkallakuri/JokeApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Joke App

Description

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.

res

Features

  • 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.

File Structure

app.py

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.

loadgif.py

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.

tts_world.py

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.

jokedata.py

Fetches a random joke from the open-source JokeAPI. This API provides both single-part and two-part jokes.

Requirements

To install the required libraries, run:

pip install -r requirements.txt

How to Run

  1. Clone the repository:

    git clone https://github.com/dheerajkallakuri/JokeApp.git
  2. Navigate to the project directory:

    cd JokeApp
  3. Run the app:

    python app.py
  4. Click the Tell me a joke! button to fetch, display, and hear a random joke, along with a laughing GIF.

Learnings & Takeaways

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.

About

Built a joke app that displays and reads jokes and GIFs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages