Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ import streamlit as st
|
|
| 2 |
import pandas as pd
|
| 3 |
import torch # Ensure PyTorch is imported
|
| 4 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 5 |
-
import speech_recognition as sr
|
| 6 |
|
| 7 |
# Load the Netflix dataset from CSV
|
| 8 |
@st.cache_data
|
|
@@ -31,36 +30,15 @@ def search_movie_details(query, data):
|
|
| 31 |
|
| 32 |
return results
|
| 33 |
|
| 34 |
-
# Function to convert voice to text
|
| 35 |
-
def voice_to_text():
|
| 36 |
-
recognizer = sr.Recognizer()
|
| 37 |
-
with sr.Microphone() as source:
|
| 38 |
-
st.write("Speak now...")
|
| 39 |
-
audio = recognizer.listen(source)
|
| 40 |
-
try:
|
| 41 |
-
return recognizer.recognize_google(audio)
|
| 42 |
-
except sr.UnknownValueError:
|
| 43 |
-
return "Sorry, I could not understand the audio."
|
| 44 |
-
except sr.RequestError:
|
| 45 |
-
return "Sorry, the speech service is down."
|
| 46 |
-
|
| 47 |
# Streamlit App
|
| 48 |
-
st.title("Netflix
|
| 49 |
|
| 50 |
# Load dataset and model
|
| 51 |
data = load_data()
|
| 52 |
tokenizer, model = load_model()
|
| 53 |
|
| 54 |
-
# Input
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
user_input = ""
|
| 58 |
-
if input_option == "Text":
|
| 59 |
-
user_input = st.text_input("Enter the movie name, director, or cast:")
|
| 60 |
-
elif input_option == "Voice":
|
| 61 |
-
if st.button("Start Recording"):
|
| 62 |
-
user_input = voice_to_text()
|
| 63 |
-
st.write(f"You said: {user_input}")
|
| 64 |
|
| 65 |
# Generate response
|
| 66 |
if user_input:
|
|
@@ -80,5 +58,3 @@ if user_input:
|
|
| 80 |
st.write("---")
|
| 81 |
else:
|
| 82 |
st.write("**I have no data about this movie. Please search another movie.**")
|
| 83 |
-
|
| 84 |
-
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import torch # Ensure PyTorch is imported
|
| 4 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
|
| 5 |
|
| 6 |
# Load the Netflix dataset from CSV
|
| 7 |
@st.cache_data
|
|
|
|
| 30 |
|
| 31 |
return results
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Streamlit App
|
| 34 |
+
st.title("Netflix Movies 🎬")
|
| 35 |
|
| 36 |
# Load dataset and model
|
| 37 |
data = load_data()
|
| 38 |
tokenizer, model = load_model()
|
| 39 |
|
| 40 |
+
# User Input (Only Text)
|
| 41 |
+
user_input = st.text_input("Enter the movie name, director, or cast:")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# Generate response
|
| 44 |
if user_input:
|
|
|
|
| 58 |
st.write("---")
|
| 59 |
else:
|
| 60 |
st.write("**I have no data about this movie. Please search another movie.**")
|
|
|
|
|
|