Create app.py
Browse filesWeb app for fine tune model
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import soundfile as sf
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
# Load your fine-tuned audio emotion classification model
|
6 |
+
model_name = "sami606713/emotion_classification"
|
7 |
+
classifier = pipeline("audio-classification", model=model_name)
|
8 |
+
|
9 |
+
# Title and description
|
10 |
+
st.title("Audio Emotion Classification")
|
11 |
+
st.write("Upload an audio file and the model will classify the emotion.")
|
12 |
+
|
13 |
+
# File uploader
|
14 |
+
uploaded_file = st.file_uploader("Choose an audio file...", type=["wav", "mp3", "ogg"])
|
15 |
+
|
16 |
+
if uploaded_file is not None:
|
17 |
+
# Load the audio file
|
18 |
+
audio_input,sample_rate=sf.read(uploaded_file)
|
19 |
+
|
20 |
+
# Display the audio player
|
21 |
+
st.audio(uploaded_file)
|
22 |
+
|
23 |
+
# Perform emotion classification
|
24 |
+
st.write("Classifying...")
|
25 |
+
predictions = classifier(audio_input)
|
26 |
+
|
27 |
+
# Display the results
|
28 |
+
for prediction in predictions:
|
29 |
+
st.write(f"Emotion: {prediction['label']}, Score: {prediction['score']:.2f}")
|