Kabatubare commited on
Commit
6f6f035
·
verified ·
1 Parent(s): 4bfe3fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -4,7 +4,6 @@ import numpy as np
4
  import torch
5
  from torch.nn.functional import softmax
6
  import librosa
7
- import soundfile as sf
8
 
9
  # Path to the local directory where the model files are stored within the Space
10
  local_model_path = "./"
@@ -28,7 +27,7 @@ def predict_voice(audio_file_path):
28
  waveform, sample_rate = librosa.load(audio_file_path, sr=16000) # Force resampling to 16000 Hz
29
 
30
  # Ensure waveform is mono
31
- if len(waveform.shape) > 1:
32
  waveform = np.mean(waveform, axis=0)
33
 
34
  # Convert the input audio file to model's expected format.
@@ -55,7 +54,7 @@ def predict_voice(audio_file_path):
55
  # Setting up the Gradio interface
56
  iface = gr.Interface(
57
  fn=predict_voice,
58
- inputs=gr.Audio(source="upload", type="filepath", label="Upload Audio File"),
59
  outputs=gr.Textbox(label="Prediction"),
60
  title="Voice Authenticity Detection",
61
  description="Detects whether a voice is real or AI-generated. Upload an audio file to see the results.",
@@ -64,5 +63,3 @@ iface = gr.Interface(
64
 
65
  # Run the Gradio interface with share=True for creating a public link
66
  iface.launch(share=True)
67
- io interface
68
- iface.launch()
 
4
  import torch
5
  from torch.nn.functional import softmax
6
  import librosa
 
7
 
8
  # Path to the local directory where the model files are stored within the Space
9
  local_model_path = "./"
 
27
  waveform, sample_rate = librosa.load(audio_file_path, sr=16000) # Force resampling to 16000 Hz
28
 
29
  # Ensure waveform is mono
30
+ if waveform.ndim > 1:
31
  waveform = np.mean(waveform, axis=0)
32
 
33
  # Convert the input audio file to model's expected format.
 
54
  # Setting up the Gradio interface
55
  iface = gr.Interface(
56
  fn=predict_voice,
57
+ inputs=gr.Audio(label="Upload Audio File", type="filepath"), # Correct parameter usage
58
  outputs=gr.Textbox(label="Prediction"),
59
  title="Voice Authenticity Detection",
60
  description="Detects whether a voice is real or AI-generated. Upload an audio file to see the results.",
 
63
 
64
  # Run the Gradio interface with share=True for creating a public link
65
  iface.launch(share=True)