Skip to content

Commit 8c47650

Browse files
committed
SpellJam fix for running outside FruitJam OS
1 parent 76842db commit 8c47650

File tree

1 file changed

+17
-6
lines changed
  • Fruit_Jam/Fruit_Jam_Spell_Jam

1 file changed

+17
-6
lines changed

Fruit_Jam/Fruit_Jam_Spell_Jam/code.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@
1212
from adafruit_bitmap_font import bitmap_font
1313
from adafruit_display_text.bitmap_label import Label
1414

15-
from launcher_config import LauncherConfig
15+
try:
16+
from launcher_config import LauncherConfig
17+
except ImportError:
18+
19+
class LauncherConfig:
20+
def __init__(self):
21+
self.data = {}
22+
self.audio_output = "headphone"
23+
self.audio_volume_override_danger = 0.75
24+
1625

1726
# comment out one of these imports depending on which TTS engine you want to use
1827
from tts_aws import WordFetcherTTS
@@ -64,13 +73,14 @@
6473

6574
word_fetcher = WordFetcherTTS(fj, launcher_config)
6675

76+
6777
def play_sound():
6878
soundPath = None
69-
if 'words' in os.listdir('spell_jam_assets'):
70-
soundPath = 'spell_jam_assets/words/'
79+
if "words" in os.listdir("spell_jam_assets"):
80+
soundPath = "spell_jam_assets/words/"
7181
else:
7282
try:
73-
sdAssets = os.listdir('/sd/spell_jam_assets/')
83+
sdAssets = os.listdir("/sd/spell_jam_assets/")
7484
soundPath = f"/sd/spell_jam_assets/{sdAssets[sdAssets.index('words')]}/"
7585
except ValueError:
7686
soundPath = None
@@ -81,11 +91,12 @@ def play_sound():
8191
for sound in os.listdir(soundPath):
8292
if sound.upper()[:-4] == lastword.upper():
8393
if sound[-4:] == ".mp3":
84-
fj.play_mp3_file(f'{soundPath}{sound}')
94+
fj.play_mp3_file(f"{soundPath}{sound}")
8595
elif sound[-4:] == ".wav":
86-
fj.play_file(f'{soundPath}{sound}')
96+
fj.play_file(f"{soundPath}{sound}")
8797
break
8898

99+
89100
def say_and_spell_lastword():
90101
"""
91102
Say the last word, then spell it out one letter at a time, finally say it once more.

0 commit comments

Comments
 (0)