Spaces:
Running
Running
sahandkh1419
commited on
Commit
•
c5afedf
1
Parent(s):
4b44c6a
Update app.py
Browse files
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.
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
|
|
121 |
else:
|
122 |
-
st.write("
|
|
|
|
|
|
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)
|