Added Script

This commit is contained in:
C20H25N3O 2020-08-23 16:24:48 +00:00
parent 220cc951b5
commit 7f85ffb996

53
main.pyw Normal file
View file

@ -0,0 +1,53 @@
from gtts import gTTS
from PIL import Image
from playsound import playsound
import os
import ctypes
import time
import shutil
import random
bg_path = os.path.normpath("C:/perawareBg")
bmp_path = os.path.normpath("C:/perawareBg/small_joe.bmp")
#defines the paths normalized for background()
def hacked(text): #defines the function that saves, and plays input as text-to-speech
tts = gTTS(text=text, lang="en")
filename = "hacked.mp3"
tts.save(filename)
playsound(filename)
def makebg(): #resizes the image smaller in order to have low resolution and saves it for background()
img = Image.open("assets/joe.jpg")
bmp = img.resize((round(img.size[0]*.25), round(img.size[1]*.25)))
bmp.save(bmp_path)
def background():
os.mkdir(bg_path) #makes a directory "C:/perawareBg"
makebg()
ctypes.windll.user32.SystemParametersInfoW(20, 0, bmp_path, 0) #saves "C:/perawareBg" to desktop wallpaper
time.sleep(1) #we needed a small pause so we would not remove the image before it was set to desktop
def clean(): #defines the function that removes the created folder and file
shutil.rmtree(bg_path) #we used shutil.rmtree as we could delete the file and folder in one line
os.remove("hacked.mp3")
def audio(): #defines the function that plays Joe Pera saying "nice" every 6 to 15 seconds then calls itself
time.sleep(random.randint(6, 15))
playsound("assets/sound.wav")
audio()
def main(): #main function
hacked("You have been hacked by the legendary comedian Joe Pera") #passes a line as input to hacked()
background()
clean()
audio()
main()