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('This is a success message!', icon="✅")