Commit
•
5f93bf1
1
Parent(s):
39f27c4
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
from SER import live_emotion_recognition
|
4 |
+
from MT import search_song_by_emotion
|
5 |
+
|
6 |
+
def audio_interface(audio):
|
7 |
+
emotion = live_emotion_recognition(audio)
|
8 |
+
preview_url = search_song_by_emotion(emotion)
|
9 |
+
if preview_url:
|
10 |
+
audio = gr.Audio(value=preview_url,label="Recommend Music 🎷")
|
11 |
+
return emotion,audio
|
12 |
+
else:
|
13 |
+
return emotion,gr.Audio(value=None,label="Unexpected Error Occured ⚠️")
|
14 |
+
|
15 |
+
description = "This is an emotion-based music recommendation system. How are you feeling today ? Hope I will help you to make you happy 😊."
|
16 |
+
|
17 |
+
css = """
|
18 |
+
#container{
|
19 |
+
margin: 0 auto;
|
20 |
+
max-width: 80rem;
|
21 |
+
}
|
22 |
+
"""
|
23 |
+
|
24 |
+
iface = gr.Interface (title='Emotion Based Recommendation System',
|
25 |
+
description=description,
|
26 |
+
fn=audio_interface,
|
27 |
+
inputs=[gr.Audio(sources='microphone', type='filepath',label="How are you feeling today ?")],
|
28 |
+
outputs=[gr.Textbox(label="Detected Emotion "),gr.Audio(label="Recommended Music 🎷")])
|
29 |
+
|
30 |
+
iface.launch()
|