fosters commited on
Commit
62429c9
·
verified ·
1 Parent(s): 9084f2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -25,16 +25,16 @@ pipe = pipeline(
25
  )
26
 
27
  # Define the function to classify an audio file
28
- def classify_audio(audio_filepath):
29
  """
30
  Takes an audio file path, classifies it using the pipeline,
31
  and returns a dictionary of top labels and their scores.
32
  """
33
- if audio_filepath is None:
34
  return "Please upload an audio file first."
35
 
36
  # The pipeline handles the loading, preprocessing, and inference.
37
- result = pipe(audio_filepath)
38
  # The output is formatted for the Gradio Label component.
39
  return {label['label']: label['score'] for label in result}
40
 
@@ -43,7 +43,7 @@ app = gr.Interface(
43
  fn=classify_audio, # Function to classify audio
44
  inputs=gr.Audio(type="filepath", label="Upload Audio"), # Input for uploading an audio file
45
  outputs=gr.Label(num_top_classes=3, label="Top 3 Predictions"), # Output with top 3 classification results
46
- title="High-Performance Audio Classification (CPU)", # App title
47
  description="Upload an audio file to classify it. This app is optimized to run on all available CPU cores.",
48
  examples=[
49
  # You can add example audio files here if you have them locally
 
25
  )
26
 
27
  # Define the function to classify an audio file
28
+ def classify_audio(audio):
29
  """
30
  Takes an audio file path, classifies it using the pipeline,
31
  and returns a dictionary of top labels and their scores.
32
  """
33
+ if audio is None:
34
  return "Please upload an audio file first."
35
 
36
  # The pipeline handles the loading, preprocessing, and inference.
37
+ result = pipe(audio)
38
  # The output is formatted for the Gradio Label component.
39
  return {label['label']: label['score'] for label in result}
40
 
 
43
  fn=classify_audio, # Function to classify audio
44
  inputs=gr.Audio(type="filepath", label="Upload Audio"), # Input for uploading an audio file
45
  outputs=gr.Label(num_top_classes=3, label="Top 3 Predictions"), # Output with top 3 classification results
46
+ title="Audio Classification", # App title
47
  description="Upload an audio file to classify it. This app is optimized to run on all available CPU cores.",
48
  examples=[
49
  # You can add example audio files here if you have them locally