File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -885,21 +885,21 @@ def play_file(self, file_name):
885
885
self .stop_tone ()
886
886
self ._speaker_enable .value = True
887
887
if file_name .lower ().endswith (".wav" ):
888
- with audiopwmio .PWMAudioOut (
889
- board . SPEAKER
890
- ) as audio , open ( file_name , "rb" ) as audio_file : # pylint: disable=not-callable
891
- wavefile = audiocore .WaveFile (audio_file )
892
- audio .play (wavefile )
893
- while audio .playing :
894
- pass
888
+ with audiopwmio .PWMAudioOut (board . SPEAKER ) as audio , open (
889
+ file_name , "rb"
890
+ ) as audio_file : # pylint: disable=not-callable
891
+ wavefile = audiocore .WaveFile (audio_file )
892
+ audio .play (wavefile )
893
+ while audio .playing :
894
+ pass
895
895
elif file_name .lower ().endswith (".mp3" ):
896
- with audiopwmio .PWMAudioOut (
897
- board . SPEAKER
898
- ) as audio , open ( file_name , "rb" ) as audio_file : # pylint: disable=not-callable
899
- mp3file = audiomp3 .MP3Decoder (audio_file )
900
- audio .play (mp3file )
901
- while audio .playing :
902
- pass
896
+ with audiopwmio .PWMAudioOut (board . SPEAKER ) as audio , open (
897
+ file_name , "rb"
898
+ ) as audio_file : # pylint: disable=not-callable
899
+ mp3file = audiomp3 .MP3Decoder (audio_file )
900
+ audio .play (mp3file )
901
+ while audio .playing :
902
+ pass
903
903
else :
904
904
raise ValueError ("Filetype must be wav or MP3." )
905
905
self ._speaker_enable .value = False
You can’t perform that action at this time.
0 commit comments