Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,18 +4,17 @@ from transformers import pipeline
|
|
| 4 |
# Initialize the audio classification pipeline with the MIT model
|
| 5 |
pipe = pipeline("audio-classification", model="MIT/ast-finetuned-audioset-10-10-0.4593")
|
| 6 |
|
| 7 |
-
# Define
|
| 8 |
def classify_audio(audio):
|
| 9 |
-
# The input audio is passed to the model for classification
|
| 10 |
result = pipe(audio)
|
| 11 |
return {label['label']: label['score'] for label in result}
|
| 12 |
|
| 13 |
# Set up the Gradio interface
|
| 14 |
app = gr.Interface(
|
| 15 |
fn=classify_audio, # Function to classify audio
|
| 16 |
-
inputs=gr.Audio(
|
| 17 |
-
outputs=gr.Label(num_top_classes=3),
|
| 18 |
-
title="Audio Classification",
|
| 19 |
description="Upload an audio file to classify it using MIT's fine-tuned AudioSet model."
|
| 20 |
)
|
| 21 |
|
|
|
|
| 4 |
# Initialize the audio classification pipeline with the MIT model
|
| 5 |
pipe = pipeline("audio-classification", model="MIT/ast-finetuned-audioset-10-10-0.4593")
|
| 6 |
|
| 7 |
+
# Define the function to classify an audio file
|
| 8 |
def classify_audio(audio):
|
|
|
|
| 9 |
result = pipe(audio)
|
| 10 |
return {label['label']: label['score'] for label in result}
|
| 11 |
|
| 12 |
# Set up the Gradio interface
|
| 13 |
app = gr.Interface(
|
| 14 |
fn=classify_audio, # Function to classify audio
|
| 15 |
+
inputs=gr.Audio(), # Input for uploading an audio file (no 'source' or 'type' needed)
|
| 16 |
+
outputs=gr.Label(num_top_classes=3), # Output with top 3 classification results
|
| 17 |
+
title="Audio Classification", # App title
|
| 18 |
description="Upload an audio file to classify it using MIT's fine-tuned AudioSet model."
|
| 19 |
)
|
| 20 |
|