RexChan commited on
Commit
a473b31
·
verified ·
1 Parent(s): fbd9ffb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -22,7 +22,7 @@ button_click = st.button("Run Analysis", type="primary")
22
 
23
  # load song
24
  input_file = "test1.mp3"
25
- output_file = ""
26
 
27
  # preprocess and crop audio file
28
  def audio_preprocess():
@@ -34,15 +34,16 @@ def audio_preprocess():
34
  start_time = 60000 # e.g. 30 seconds, 30000
35
  end_time = 110000 # e.g. 40 seconds, 40000
36
 
37
- audio = AudioSegment.from_file('/test1/vocals.wav')
38
  cropped_audio = audio[start_time:end_time]
39
- cropped_audio.export('cropped_vocals.wav', format='wav') # save vocal audio file
40
 
41
 
42
  # ASR transcription
43
  def asr_model():
44
  # load audio file
45
- y, sr = librosa.load('cropped_vocals.wav', sr=16000)
 
46
 
47
  # ASR model
48
  MODEL_NAME = "RexChan/ISOM5240-whisper-small-zhhk_1"
 
22
 
23
  # load song
24
  input_file = "test1.mp3"
25
+ output_file = os.path.join(os.path.dirname(__file__)
26
 
27
  # preprocess and crop audio file
28
  def audio_preprocess():
 
34
  start_time = 60000 # e.g. 30 seconds, 30000
35
  end_time = 110000 # e.g. 40 seconds, 40000
36
 
37
+ audio = AudioSegment.from_file(os.path.join(os.path.dirname(__file__), 'vocals.wav'))
38
  cropped_audio = audio[start_time:end_time]
39
+ cropped_audio.export(os.path.join(os.path.dirname(__file__), 'cropped_vocals.wav'), format='wav') # save vocal audio file
40
 
41
 
42
  # ASR transcription
43
  def asr_model():
44
  # load audio file
45
+ #y, sr = librosa.load('cropped_vocals.wav', sr=16000)
46
+ y, sr = librosa.load(os.path.join(os.path.dirname(__file__), 'cropped_vocals.wav'), sr=16000)
47
 
48
  # ASR model
49
  MODEL_NAME = "RexChan/ISOM5240-whisper-small-zhhk_1"