Skip to content

Commit

Permalink
Merge branch 'Relativiteit-Voice-Generator' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
NozomuYoshida committed Sep 19, 2021
2 parents 82f2f26 + 67d34c4 commit e009d08
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Binary file added kanye.mp3
Binary file not shown.
Binary file added kanye.ogg
Binary file not shown.
20 changes: 18 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from tkinter import *
import requests
from gtts import gTTS
import os
import pygame
from os import path
from pydub import AudioSegment


def get_quote():
URL = 'https://api.kanye.rest'
Expand All @@ -8,6 +14,15 @@ def get_quote():
quote = response.json()['quote']
canvas.itemconfig(quote_text, text=quote)

kanye_voice = quote
language = 'en'
kanye_object = gTTS(text=kanye_voice, lang=language, slow=False)
kanye_object.save("kanye.mp3")
AudioSegment.from_mp3("kanye.mp3").export('kanye.ogg', format='ogg')
pygame.mixer.init()
pygame.mixer.music.load("kanye.ogg")
pygame.mixer.music.play(loops=0)


window = Tk()
window.title("Kanye Says...")
Expand All @@ -16,12 +31,13 @@ def get_quote():
canvas = Canvas(width=300, height=414)
background_img = PhotoImage(file="background.gif")
canvas.create_image(150, 207, image=background_img)
quote_text = canvas.create_text(150, 207, text="Kanye Quote Goes HERE", width=250, font=("Arial", 30, "bold"), fill="white")
quote_text = canvas.create_text(150, 207, text="Kanye Quote Goes HERE", width=250, font=(
"Arial", 30, "bold"), fill="white")
canvas.grid(row=0, column=0)

kanye_img = PhotoImage(file="kanye.gif")
kanye_button = Button(image=kanye_img, highlightthickness=0, command=get_quote)
kanye_button.grid(row=1, column=0)


window.mainloop()
window.mainloop()

0 comments on commit e009d08

Please sign in to comment.