RexChan commited on
Commit
da6a573
1 Parent(s): f7d6f3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -12,16 +12,17 @@ import accelerate
12
  # steamlit setup
13
  st.set_page_config(page_title="Sentiment Analysis on Your Cantonese Song",)
14
  st.header("Cantonese Song Sentiment Analyzer")
15
- input_file = st.file_uploader("upload a song in mp3 format", type="mp3") # upload song
16
- if input_file is not None:
17
- st.write("File uploaded successfully!")
18
- st.write(input_file)
19
- else:
20
- st.write("No file uploaded.")
21
  button_click = st.button("Run Analysis", type="primary")
22
 
23
  # load song
24
- output_file = ""
 
25
 
26
  # preprocess and crop audio file
27
  def audio_preprocess():
@@ -33,15 +34,15 @@ def audio_preprocess():
33
  start_time = 60000 # e.g. 30 seconds, 30000
34
  end_time = 110000 # e.g. 40 seconds, 40000
35
 
36
- audio = AudioSegment.from_file('/ISOM5240_Group25/vocals.wav')
37
  cropped_audio = audio[start_time:end_time]
38
- cropped_audio.export('/ISOM5240_Group25/cropped_vocals.wav', format='wav') # save vocal audio file
39
 
40
 
41
  # ASR transcription
42
  def asr_model():
43
  # load audio file
44
- y, sr = librosa.load('/ISOM5240_Group25/cropped_vocals.wav', sr=16000)
45
 
46
  # ASR model
47
  MODEL_NAME = "RexChan/ISOM5240-whisper-small-zhhk_1"
 
12
  # steamlit setup
13
  st.set_page_config(page_title="Sentiment Analysis on Your Cantonese Song",)
14
  st.header("Cantonese Song Sentiment Analyzer")
15
+ #input_file = st.file_uploader("upload a song in mp3 format", type="mp3") # upload song
16
+ #if input_file is not None:
17
+ #st.write("File uploaded successfully!")
18
+ #st.write(input_file)
19
+ #else:
20
+ #st.write("No file uploaded.")
21
  button_click = st.button("Run Analysis", type="primary")
22
 
23
  # load song
24
+ input_file = os.path.isfile("test1.mp3")
25
+ output_file = os.path.isdir("")
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('/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"