Last active
February 9, 2025 00:16
-
-
Save exurd/c116ece33194980a25241e800749bc00 to your computer and use it in GitHub Desktop.
Python Script from 2022: This script plays a random meme after a random amount of time has passed. (Replicates this: https://vm.tiktok.com/ZM8ET3DhM/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame # pip install pygame | |
import glob | |
import random | |
from random import randint | |
import time | |
pygame.mixer.init() | |
soundfiles = glob.glob("memes/*.mp3") # grab mp3s in a folder called memes. you can use 'yt-dlp -f 251 -x --audio-format mp3 -o %(id)s.%(ext)s [LINK TO YT]' to download memes | |
while True: | |
timer = randint(6, 180) | |
# timer = 1 # to test | |
print("sleeping for ",timer," seconds") | |
time.sleep(timer) | |
sound = random.choice(soundfiles) | |
print("playing ",sound) | |
pygame.mixer.music.load(sound) | |
pygame.mixer.music.play() # play the funny sound |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment