From b14b39ee3f45b8c325e3973a3ea28467c42c64c0 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Sat, 15 Nov 2025 13:32:52 -0500 Subject: [PATCH 1/2] Spell_Jam: Add word sounds --- Fruit_Jam/Fruit_Jam_Spell_Jam/code.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Fruit_Jam/Fruit_Jam_Spell_Jam/code.py b/Fruit_Jam/Fruit_Jam_Spell_Jam/code.py index 5ba543abe..274e635f2 100644 --- a/Fruit_Jam/Fruit_Jam_Spell_Jam/code.py +++ b/Fruit_Jam/Fruit_Jam_Spell_Jam/code.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import sys +import os import time import supervisor @@ -81,6 +82,27 @@ def say_and_spell_lastword(): fj.play_mp3_file(word_fetcher.output_path) elif word_fetcher.output_path[-4:] == ".wav": fj.play_file(word_fetcher.output_path) + soundPath = None + if 'words' in os.listdir('spell_jam_assets'): + soundPath = 'spell_jam_assets/words/' + else: + try: + sdAssets = os.listdir('/sd/spell_jam_assets/') + soundPath = f"/sd/spell_jam_assets/{sdAssets[sdAssets.index('words')]}/" + except ValueError: + soundPath = None + except OSError: + soundPath = None + + if soundPath is not None: + for sound in os.listdir(soundPath): + if sound.upper()[:-4] == lastword.upper(): + if sound[-4:] == ".mp3": + fj.play_mp3_file(f'{soundPath}{sound}') + elif sound[-4:] == ".wav": + fj.play_file(f'{soundPath}{sound}') + break + fj.neopixels.fill(0x000000) From 1f5fbdb4b936d46fa53c37f7a6db50e7e7768651 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Sat, 15 Nov 2025 13:50:15 -0500 Subject: [PATCH 2/2] try and make pylint happy.... --- Fruit_Jam/Fruit_Jam_Spell_Jam/code.py | 39 ++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/Fruit_Jam/Fruit_Jam_Spell_Jam/code.py b/Fruit_Jam/Fruit_Jam_Spell_Jam/code.py index 274e635f2..a50bbb46e 100644 --- a/Fruit_Jam/Fruit_Jam_Spell_Jam/code.py +++ b/Fruit_Jam/Fruit_Jam_Spell_Jam/code.py @@ -64,24 +64,7 @@ word_fetcher = WordFetcherTTS(fj, launcher_config) -def say_and_spell_lastword(): - """ - Say the last word, then spell it out one letter at a time, finally say it once more. - """ - if sayword: - if word_fetcher.output_path[-4:] == ".mp3": - fj.play_mp3_file(word_fetcher.output_path) - elif word_fetcher.output_path[-4:] == ".wav": - fj.play_file(word_fetcher.output_path) - time.sleep(0.2) - for letter in lastword: - fj.play_mp3_file(f"spell_jam_assets/letter_mp3s/{letter.upper()}.mp3") - time.sleep(0.2) - if sayword: - if word_fetcher.output_path[-4:] == ".mp3": - fj.play_mp3_file(word_fetcher.output_path) - elif word_fetcher.output_path[-4:] == ".wav": - fj.play_file(word_fetcher.output_path) +def play_sound(): soundPath = None if 'words' in os.listdir('spell_jam_assets'): soundPath = 'spell_jam_assets/words/' @@ -103,6 +86,26 @@ def say_and_spell_lastword(): fj.play_file(f'{soundPath}{sound}') break +def say_and_spell_lastword(): + """ + Say the last word, then spell it out one letter at a time, finally say it once more. + """ + if sayword: + if word_fetcher.output_path[-4:] == ".mp3": + fj.play_mp3_file(word_fetcher.output_path) + elif word_fetcher.output_path[-4:] == ".wav": + fj.play_file(word_fetcher.output_path) + time.sleep(0.2) + for letter in lastword: + fj.play_mp3_file(f"spell_jam_assets/letter_mp3s/{letter.upper()}.mp3") + time.sleep(0.2) + if sayword: + if word_fetcher.output_path[-4:] == ".mp3": + fj.play_mp3_file(word_fetcher.output_path) + elif word_fetcher.output_path[-4:] == ".wav": + fj.play_file(word_fetcher.output_path) + play_sound() + fj.neopixels.fill(0x000000)