camparchimedes commited on
Commit
f49fe3c
·
verified ·
1 Parent(s): 7ee498a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -62,13 +62,14 @@ SIDEBAR_INFO = f"""
62
 
63
 
64
 
65
- # ============ORIGINAL============[convert m4a audio to wav]
66
  @spaces.GPU()
67
- def convert_to_wav(audio_file):
68
- audio = AudioSegment.from_file(audio_file, format="m4a")
69
- wav_file = "temp.wav"
70
- audio.export(wav_file, format="wav")
71
- return wav_file
 
72
  # ================================[------------------------]
73
 
74
 
 
62
 
63
 
64
 
65
+ # ============UPDATED============[convert m4a audio to wav]
66
  @spaces.GPU()
67
+ def convert_to_wav(filepath):
68
+ _,file_ending = os.path.splitext(f'{filepath}')
69
+ audio_file = filepath.replace(file_ending, ".wav")
70
+ print("starting conversion to wav")
71
+ os.system(f'ffmpeg -i "{filepath}" -ar 16000 -ac 1 -c:a pcm_s16le "{audio_file}"')
72
+ return audio_file
73
  # ================================[------------------------]
74
 
75