Spaces:
Runtime error
Runtime error
File size: 1,313 Bytes
edc4276 01e4bba c4d5407 401d1a7 edc4276 01e4bba edc4276 c4d5407 edc4276 01e4bba edc4276 01e4bba edc4276 01e4bba edc4276 |
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 29 30 31 32 33 34 35 36 37 38 39 |
import streamlit as st
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences
import joblib
import pandas as pd
import numpy as np
# Load your models
emotion_model = load_model('lstm_model.h5')
recommender_model = joblib.load('knn_model.npy')
#load the dataset
# df = pd.read_csv('path_to_your_dataframe.csv')
st.title("Emotion-based Song Recommender")
# User input for lyrics
lyrics = st.text_area("Enter lyrics here:")
if st.button("Recommend Songs"):
if lyrics:
# Predict emotion
# Here, ensure that the input shape and preprocessing of lyrics
# match the requirements of your LSTM model
sequence = tokenizer.texts_to_sequences([lyrics])
padded_sequence = pad_sequences(sequence, maxlen=128)
emotion = emotion_model.predict(padded_sequence) # Adjust this as per your model's requirement
# Get song recommendations
# The recommend method should be defined as part of your KNN model
# or as a separate function that uses the KNN model
recommendations = recommender_model.recommend(emotion, ...)
st.write("Emotion Detected:", emotion)
st.write("Recommended Songs:", recommendations)
|