Spaces:
Running
Running
sahandkh1419
commited on
Commit
•
4b44c6a
1
Parent(s):
b884b0f
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import whisper
|
|
3 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
4 |
from sklearn.metrics.pairwise import cosine_similarity
|
5 |
import base64
|
|
|
6 |
|
7 |
st.set_page_config(
|
8 |
page_title="Sing It Forward App",
|
@@ -105,4 +106,17 @@ with tab2:
|
|
105 |
if uploaded_file is not None:
|
106 |
with open("raw_music.mp3", "wb") as f:
|
107 |
f.write(uploaded_file.getbuffer())
|
108 |
-
st.audio("raw_music.mp3")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
4 |
from sklearn.metrics.pairwise import cosine_similarity
|
5 |
import base64
|
6 |
+
from pydub import AudioSegment
|
7 |
|
8 |
st.set_page_config(
|
9 |
page_title="Sing It Forward App",
|
|
|
106 |
if uploaded_file is not None:
|
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!")
|