Commit
•
01ce6f2
1
Parent(s):
6781020
Update app.py
Browse files
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 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
gr.
|
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 |
-
|
|
|
|
|
|
|
|
|
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()
|