Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,18 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import whisper
|
|
|
|
|
|
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
model = whisper.load_model("base")
|
| 5 |
st.audio("titanic.mp3")
|
| 6 |
-
st.write("
|
| 7 |
|
| 8 |
-
audio_value = st.experimental_audio_input("
|
| 9 |
lyrics = "Far across the distance And spaces between us You have come to show you go on"
|
| 10 |
|
| 11 |
if audio_value:
|
|
@@ -14,4 +21,6 @@ if audio_value:
|
|
| 14 |
|
| 15 |
user_lyrics = model.transcribe("user_sing.mp3")["text"]
|
| 16 |
st.write(user_lyrics)
|
| 17 |
-
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import whisper
|
| 3 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 4 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
| 5 |
|
| 6 |
+
def cosine_sim(text1, text2):
|
| 7 |
+
vectorizer = TfidfVectorizer().fit_transform([text1, text2])
|
| 8 |
+
vectors = vectorizer.toarray()
|
| 9 |
+
return cosine_similarity(vectors)[0, 1]
|
| 10 |
+
|
| 11 |
model = whisper.load_model("base")
|
| 12 |
st.audio("titanic.mp3")
|
| 13 |
+
st.write("Listen to music since you have to record 15seconds after that")
|
| 14 |
|
| 15 |
+
audio_value = st.experimental_audio_input("Sing Rest of music:🎙️")
|
| 16 |
lyrics = "Far across the distance And spaces between us You have come to show you go on"
|
| 17 |
|
| 18 |
if audio_value:
|
|
|
|
| 21 |
|
| 22 |
user_lyrics = model.transcribe("user_sing.mp3")["text"]
|
| 23 |
st.write(user_lyrics)
|
| 24 |
+
similarity_score = cosine_sim(lyrics, user_lyrics)
|
| 25 |
+
if similarity_score > 0.85:
|
| 26 |
+
st.success('This is a success message!', icon="✅")
|