diff options
| author | yum <yum.food.vr@gmail.com> | 2023-09-01 01:06:44 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2023-09-01 01:06:44 -0700 |
| commit | 6753d81627d4467e649a6bb8dcb44c7eb8e42e1e (patch) | |
| tree | a94bdfac8c9b1ccfbf557177eb76267e0eb3c318 /Sounds | |
| parent | 749854018ff279e3aadd60d89ac7354886d1630d (diff) | |
Various cleanup
Diffstat (limited to 'Sounds')
| -rw-r--r-- | Sounds/aiueo/play.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/Sounds/aiueo/play.py b/Sounds/aiueo/play.py deleted file mode 100644 index 674cf2e..0000000 --- a/Sounds/aiueo/play.py +++ /dev/null @@ -1,40 +0,0 @@ -import winsound -import os -import random -import time - -def get_wav_files_in_cwd(): - """Returns a list of .wav files in the current working directory.""" - cwd = os.path.dirname(os.path.abspath(__file__)) - return [os.path.join(cwd, f) for f in os.listdir(cwd) if f.endswith('.wav')] - -# Pro tip: wrap this in a predicate -def play_random_wav(wav_files): - """Plays a random .wav file from the provided list asynchronously.""" - random_file = random.choice(wav_files) - winsound.PlaySound(random_file, winsound.SND_FILENAME | winsound.SND_ASYNC) - -def probably_play_random_wav(wav_files): - """Plays a random .wav file from the list. Probably.""" - if random.randint(1,3) == 1: - play_random_wav(wav_files) - -def main(): - wav_files = get_wav_files_in_cwd() - for file in wav_files: - print(f"file get: {file}") - if not wav_files: - print("No .wav files found in the current directory.") - return - - try: - while True: - probably_play_random_wav(wav_files) - time.sleep(0.04) - except KeyboardInterrupt: - print("Program terminated by user.") - winsound.PlaySound(None, winsound.SND_PURGE) # Stop any ongoing asynchronous sounds - -if __name__ == "__main__": - main() - |
