Spaces:
Sleeping
Sleeping
File size: 1,035 Bytes
5d20072 dea462a 1e85041 dea462a 1e85041 dea462a 1a2e1f9 1e85041 5d20072 1e85041 1a2e1f9 5d20072 d344ece dea462a 1e85041 87479c7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import streamlit as st
import whisper
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
def cosine_sim(text1, text2):
vectorizer = TfidfVectorizer().fit_transform([text1, text2])
vectors = vectorizer.toarray()
return cosine_similarity(vectors)[0, 1]
model = whisper.load_model("base")
st.audio("titanic.mp3")
st.write("Listen to music since you have to record 15seconds after that")
audio_value = st.experimental_audio_input("Sing Rest of music:🎙️")
lyrics = "Far across the distance And spaces between us You have come to show you go on"
if audio_value:
with open("user_sing.mp3", "wb") as f:
f.write(audio_value.getbuffer())
user_lyrics = model.transcribe("user_sing.mp3")["text"]
st.write(user_lyrics)
similarity_score = cosine_sim(lyrics, user_lyrics)
if similarity_score > 0.85:
st.success('Awsome! You are doing great', icon="✅")
else:
st.error('Awful! Try harder next time', icon="🚨") |