File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Fruit_Jam/Fruit_Jam_Spell_Jam Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: MIT
33
44import sys
5+ import os
56import time
67import supervisor
78
@@ -81,6 +82,27 @@ def say_and_spell_lastword():
8182 fj .play_mp3_file (word_fetcher .output_path )
8283 elif word_fetcher .output_path [- 4 :] == ".wav" :
8384 fj .play_file (word_fetcher .output_path )
85+ soundPath = None
86+ if 'words' in os .listdir ('spell_jam_assets' ):
87+ soundPath = 'spell_jam_assets/words/'
88+ else :
89+ try :
90+ sdAssets = os .listdir ('/sd/spell_jam_assets/' )
91+ soundPath = f"/sd/spell_jam_assets/{ sdAssets [sdAssets .index ('words' )]} /"
92+ except ValueError :
93+ soundPath = None
94+ except OSError :
95+ soundPath = None
96+
97+ if soundPath is not None :
98+ for sound in os .listdir (soundPath ):
99+ if sound .upper ()[:- 4 ] == lastword .upper ():
100+ if sound [- 4 :] == ".mp3" :
101+ fj .play_mp3_file (f'{ soundPath } { sound } ' )
102+ elif sound [- 4 :] == ".wav" :
103+ fj .play_file (f'{ soundPath } { sound } ' )
104+ break
105+
84106 fj .neopixels .fill (0x000000 )
85107
86108
You can’t perform that action at this time.
0 commit comments