File size: 1,044 Bytes
5f93bf1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a86130
5f93bf1
 
 
 
 
 
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
import gradio as gr

from SER import live_emotion_recognition
from MT import search_song_by_emotion

def audio_interface(audio):
    emotion = live_emotion_recognition(audio)
    preview_url = search_song_by_emotion(emotion)
    if preview_url:
      audio = gr.Audio(value=preview_url,label="Recommend Music 🎷")
      return emotion,audio
    else:
      return emotion,gr.Audio(value=None,label="Unexpected Error Occured ⚠️")

description = "This is an emotion-based music recommendation system. How are you feeling today ? Hope I will help you to make you happy 😊."

css = """
#container{
    margin: 0 auto;
    max-width: 80rem;
}
"""

iface = gr.Interface (title='Sentiment based Music Therapy',
                      description=description,
                      fn=audio_interface,
                      inputs=[gr.Audio(sources='microphone', type='filepath',label="How are you feeling today ?")],
                      outputs=[gr.Textbox(label="Detected Emotion "),gr.Audio(label="Recommended Music 🎷")])

iface.launch()