Kabatubare commited on
Commit
01ce6f2
1 Parent(s): 6781020

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -13
app.py CHANGED
@@ -30,7 +30,7 @@ def plot_spectrogram(waveform, sr):
30
  S = librosa.feature.melspectrogram(y=waveform, sr=sr, n_mels=128)
31
  S_DB = librosa.power_to_db(S, ref=np.max)
32
  plt.figure(figsize=(12, 6))
33
- librosa.display.specshow(S_DB, sr=sr, x_axis='time', y_axis='mel')
34
  plt.title('Mel Spectrogram')
35
  plt.colorbar(format='%+2.0f dB')
36
  plt.tight_layout()
@@ -94,18 +94,24 @@ def predict_voice(audio_file_path):
94
  return f"Error during processing: {e}", None, None, ""
95
 
96
  iface = gr.Interface(
97
- fn=predict_voice,
98
- inputs=gr.Audio(label="Upload Audio File", type="filepath"),
99
- outputs=[
100
- gr.Textbox(label="Prediction"),
101
- gr.Textbox(label="Transcription"), # Added comma here
102
- gr.Image(label="Spectrogram"),
103
- gr.Image(label="Waveform"),
104
- ],
105
- title="Voice Clone Detection",
106
- description="Detects whether a voice is real or an AI-generated clone. Upload an audio file to see the results."
107
- )
108
 
109
- iface.launch()
 
 
 
 
110
 
 
 
 
 
 
 
111
 
 
 
30
  S = librosa.feature.melspectrogram(y=waveform, sr=sr, n_mels=128)
31
  S_DB = librosa.power_to_db(S, ref=np.max)
32
  plt.figure(figsize=(12, 6))
33
+ librosa.display.specshow(S_DB, sr=sr, x_axis='time', y_axis='mel', cmap='inferno')
34
  plt.title('Mel Spectrogram')
35
  plt.colorbar(format='%+2.0f dB')
36
  plt.tight_layout()
 
94
  return f"Error during processing: {e}", None, None, ""
95
 
96
  iface = gr.Interface(
97
+ with gr.Blocks(css="style.css") as demo:
98
+ gr.Markdown("## Voice Clone Detection")
99
+ gr.Markdown("Detects whether a voice is real or an AI-generated clone. Upload an audio file to see the results.")
100
+
101
+ with gr.Row():
102
+ audio_input = gr.Audio(label="Upload Audio File", type="filepath")
 
 
 
 
 
103
 
104
+ with gr.Row():
105
+ prediction_output = gr.Textbox(label="Prediction")
106
+ waveform_output = gr.Image(label="Waveform")
107
+ spectrogram_output = gr.Image(label="Spectrogram")
108
+ transcription_output = gr.Textbox(label="Transcription")
109
 
110
+ detect_button = gr.Button("Detect Voice Clone")
111
+ detect_button.click(
112
+ fn=predict_voice,
113
+ inputs=audio_input,
114
+ outputs=[prediction_output, waveform_output, spectrogram_output, transcription_output]
115
+ )
116
 
117
+ demo.launch()