Zw07 commited on
Commit
1b40679
·
verified ·
1 Parent(s): 6213c17

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -128,10 +128,19 @@ def main():
128
 
129
  # Save file to local storage
130
  tmp_input_audio_file = os.path.join("/tmp/", audio_file.name)
131
- with open("test.wav", "wb") as f:
132
- f.write(audio_file.getbuffer())
 
 
 
133
 
134
- st.audio("test.wav", format="audio/wav")
 
 
 
 
 
 
135
 
136
  # # Convert MP3 to WAV using pydub
137
  # mp3_audio = AudioSegment.from_mp3(tmp_input_audio_file)
 
128
 
129
  # Save file to local storage
130
  tmp_input_audio_file = os.path.join("/tmp/", audio_file.name)
131
+ file_extension = os.path.splitext(audio_file)[1].lower()
132
+ st.markdown(file_extension)
133
+ if file_extension in [".wav", ".flac"]:
134
+ with open("test.wav", "wb") as f:
135
+ f.write(audio_file.getbuffer())
136
 
137
+ st.audio("test.wav", format="audio/wav")
138
+
139
+ elif file_extension == ".mp3":
140
+ with open("test.mp3", "wb") as f:
141
+ f.write(audio_file.getbuffer())
142
+
143
+ st.audio("test.wav", format="audio/mpeg")
144
 
145
  # # Convert MP3 to WAV using pydub
146
  # mp3_audio = AudioSegment.from_mp3(tmp_input_audio_file)