seikin_alexey commited on
Commit
2355a75
1 Parent(s): baeee65
Files changed (2) hide show
  1. README.md +1 -1
  2. app3.py +37 -0
README.md CHANGED
@@ -5,7 +5,7 @@ colorFrom: green
5
  colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 3.0.19
8
- app_file: app2.py
9
  pinned: false
10
  duplicated_from: harish3110/emotion_detection
11
  ---
 
5
  colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 3.0.19
8
+ app_file: app3.py
9
  pinned: false
10
  duplicated_from: harish3110/emotion_detection
11
  ---
app3.py CHANGED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from speechbrain.pretrained.interfaces import foreign_class
2
+ import gradio as gr
3
+ import os
4
+ import warnings
5
+ warnings.filterwarnings("ignore")
6
+
7
+ # ... [rest of your code remains unchanged] ...
8
+
9
+ # Get the list of audio files for the dropdown
10
+ audio_files_list = get_audio_files_list()
11
+
12
+ # Function to return the selected audio file path
13
+ def get_audio_file_path(selected_audio):
14
+ file_path = os.path.join("rec", selected_audio)
15
+ return file_path
16
+
17
+ # Gradio components
18
+ dropdown = gr.Dropdown(label="Select Audio", choices=audio_files_list)
19
+ audio_player = gr.Audio(source="file", label="Listen to the selected audio")
20
+
21
+ # Update the audio player when a new selection is made from the dropdown
22
+ def update_audio(selected_audio):
23
+ return get_audio_file_path(selected_audio)
24
+
25
+ # Connect the dropdown to the audio player using the update_audio function
26
+ dropdown.change(fn=update_audio, inputs=dropdown, outputs=audio_player)
27
+
28
+ # Update the Gradio interface to use both the dropdown and the audio player as inputs
29
+ interface = gr.Interface(
30
+ fn=predict_emotion,
31
+ inputs=[dropdown, audio_player],
32
+ outputs="text",
33
+ title="ML Speech Emotion Detection",
34
+ description="Speechbrain powered wav2vec 2.0 pretrained model on IEMOCAP dataset using Gradio."
35
+ )
36
+
37
+ interface.launch()