sahandkh1419 commited on
Commit
c5afedf
1 Parent(s): 4b44c6a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -107,16 +107,22 @@ with tab2:
107
  with open("raw_music.mp3", "wb") as f:
108
  f.write(uploaded_file.getbuffer())
109
  st.audio("raw_music.mp3")
110
- st.write("Specify start and end times for trimming:")
111
- audio = AudioSegment.from_file("raw_music.mp3")
112
- duration = len(audio) // 1000
113
- start_time = st.number_input("Start Time (seconds)", min_value=0, max_value=duration, value=0)
114
- end_time = st.number_input("End Time (seconds)", min_value=0, max_value=duration, value=duration)
115
- if start_time < end_time:
116
- trimmed_audio = audio[start_time * 1000:end_time * 1000]
117
- trimmed_audio.export("trimmed_music.mp3", format="mp3")
118
- st.write("Now type what user should sing:")
119
- user_input = st.text_area("Lyrics to be singed:")
120
- st.write(user_input)
 
 
 
 
121
  else:
122
- st.write("Start Time should be smaller than End Time!")
 
 
 
107
  with open("raw_music.mp3", "wb") as f:
108
  f.write(uploaded_file.getbuffer())
109
  st.audio("raw_music.mp3")
110
+ trimm_check = st.checkbox("Trim?")
111
+ if trimm_check:
112
+ st.write("Specify start and end times for trimming:")
113
+ audio = AudioSegment.from_file("raw_music.mp3")
114
+ duration = len(audio) // 1000
115
+ start_time = st.number_input("Start Time (seconds)", min_value=0, max_value=duration, value=0)
116
+ end_time = st.number_input("End Time (seconds)", min_value=0, max_value=duration, value=duration)
117
+ if start_time < end_time:
118
+ trimmed_audio = audio[start_time * 1000:end_time * 1000]
119
+ trimmed_audio.export("trimmed_music.mp3", format="mp3")
120
+ st.write("Now type what user should sing:")
121
+ lyrics = st.text_area("Lyrics to be singed:")
122
+ st.write(lyrics)
123
+ else:
124
+ st.write("Start Time should be smaller than End Time!")
125
  else:
126
+ st.write("Now type what user should sing:")
127
+ lyrics = st.text_area("Lyrics to be singed:")
128
+ st.write(lyrics)