Skip to content

Instantly share code, notes, and snippets.

@megahomyak
Created August 26, 2022 13:10
Show Gist options
  • Save megahomyak/147cb030e85fb204b07a1a1f8c8dfa3d to your computer and use it in GitHub Desktop.
Save megahomyak/147cb030e85fb204b07a1a1f8c8dfa3d to your computer and use it in GitHub Desktop.
A tiny soundboard written in three minutes.
from readchar import readchar
from playsound import playsound
import os
sound_names = os.listdir("sounds")
letters_to_names = dict(zip("abcdefghijklmnopqrstuvwxyz1234567890", sound_names))
for letter, name in letters_to_names.items():
print(f"{letter} - {name}")
while True:
try:
playsound(os.path.join("sounds", letters_to_names[readchar()]), block=False)
except KeyError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment