Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,28 +2,10 @@ import streamlit as st
|
|
2 |
from transformers import pipeline
|
3 |
import google.generativeai as genai
|
4 |
from pytube import Search
|
5 |
-
import speech_recognition as sr
|
6 |
|
7 |
# Load sentiment analysis model
|
8 |
mood_classifier = pipeline("sentiment-analysis")
|
9 |
|
10 |
-
# Speech-to-text function
|
11 |
-
def speech_to_text():
|
12 |
-
recognizer = sr.Recognizer()
|
13 |
-
with sr.Microphone() as source:
|
14 |
-
st.write("🎤 Speak now...")
|
15 |
-
audio = recognizer.listen(source)
|
16 |
-
try:
|
17 |
-
text = recognizer.recognize_google(audio)
|
18 |
-
st.write(f"🎤 You said: **{text}**")
|
19 |
-
return text
|
20 |
-
except sr.UnknownValueError:
|
21 |
-
st.error("Sorry, I could not understand your audio.")
|
22 |
-
return None
|
23 |
-
except sr.RequestError:
|
24 |
-
st.error("Sorry, there was an issue with the speech recognition service.")
|
25 |
-
return None
|
26 |
-
|
27 |
# Functions
|
28 |
def detect_mood(text):
|
29 |
result = mood_classifier(text)[0]
|
@@ -77,11 +59,8 @@ mood_options = ["happy", "sad", "energetic", "romantic", "calm"]
|
|
77 |
# Input for Gemini API key
|
78 |
gemini_api_key = st.sidebar.text_input("Enter your Gemini API Key:", type="password")
|
79 |
|
80 |
-
# Add a button for
|
81 |
-
|
82 |
-
user_mood = speech_to_text()
|
83 |
-
else:
|
84 |
-
user_mood = st.sidebar.selectbox("Or select your mood:", mood_options)
|
85 |
|
86 |
# Playlist
|
87 |
if 'playlist' not in st.session_state:
|
|
|
2 |
from transformers import pipeline
|
3 |
import google.generativeai as genai
|
4 |
from pytube import Search
|
|
|
5 |
|
6 |
# Load sentiment analysis model
|
7 |
mood_classifier = pipeline("sentiment-analysis")
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Functions
|
10 |
def detect_mood(text):
|
11 |
result = mood_classifier(text)[0]
|
|
|
59 |
# Input for Gemini API key
|
60 |
gemini_api_key = st.sidebar.text_input("Enter your Gemini API Key:", type="password")
|
61 |
|
62 |
+
# Add a button for mood input
|
63 |
+
user_mood = st.sidebar.selectbox("Select your mood:", mood_options)
|
|
|
|
|
|
|
64 |
|
65 |
# Playlist
|
66 |
if 'playlist' not in st.session_state:
|