File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Fruit_Jam/Fruit_Jam_Spell_Jam Expand file tree Collapse file tree 1 file changed +25
-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
6364
6465word_fetcher = WordFetcherTTS (fj , launcher_config )
6566
67+ def play_sound ():
68+ soundPath = None
69+ if 'words' in os .listdir ('spell_jam_assets' ):
70+ soundPath = 'spell_jam_assets/words/'
71+ else :
72+ try :
73+ sdAssets = os .listdir ('/sd/spell_jam_assets/' )
74+ soundPath = f"/sd/spell_jam_assets/{ sdAssets [sdAssets .index ('words' )]} /"
75+ except ValueError :
76+ soundPath = None
77+ except OSError :
78+ soundPath = None
79+
80+ if soundPath is not None :
81+ for sound in os .listdir (soundPath ):
82+ if sound .upper ()[:- 4 ] == lastword .upper ():
83+ if sound [- 4 :] == ".mp3" :
84+ fj .play_mp3_file (f'{ soundPath } { sound } ' )
85+ elif sound [- 4 :] == ".wav" :
86+ fj .play_file (f'{ soundPath } { sound } ' )
87+ break
88+
6689def say_and_spell_lastword ():
6790 """
6891 Say the last word, then spell it out one letter at a time, finally say it once more.
@@ -81,6 +104,8 @@ def say_and_spell_lastword():
81104 fj .play_mp3_file (word_fetcher .output_path )
82105 elif word_fetcher .output_path [- 4 :] == ".wav" :
83106 fj .play_file (word_fetcher .output_path )
107+ play_sound ()
108+
84109 fj .neopixels .fill (0x000000 )
85110
86111
You can’t perform that action at this time.
0 commit comments