Kabatubare commited on
Commit
16802ac
·
verified ·
1 Parent(s): accc14f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -50,14 +50,22 @@ def predict_voice(audio_file_path):
50
 
51
  logits = (outputs_original.logits + outputs_augmented.logits) / 2
52
  predicted_index = logits.argmax()
53
- label = model.config.id2label[predicted_index.item()]
54
  confidence = torch.softmax(logits, dim=1).max().item() * 100
55
 
 
 
 
 
 
 
 
 
56
  waveform_plot = plot_waveform(waveform, sample_rate)
57
  spectrogram_plot = plot_spectrogram(waveform, sample_rate)
58
 
59
  return (
60
- f"The voice is classified as '{label}' with a confidence of {confidence:.2f}%.",
61
  waveform_plot,
62
  spectrogram_plot
63
  )
 
50
 
51
  logits = (outputs_original.logits + outputs_augmented.logits) / 2
52
  predicted_index = logits.argmax()
53
+ original_label = model.config.id2label[predicted_index.item()]
54
  confidence = torch.softmax(logits, dim=1).max().item() * 100
55
 
56
+ # Map original labels to new labels
57
+ label_mapping = {
58
+ "Spoof": "AI-generated Clone",
59
+ "Bonafide": "Real Human Voice"
60
+ }
61
+ # Use the original label to get the new label
62
+ new_label = label_mapping.get(original_label, "Unknown") # Default to "Unknown" if label not found
63
+
64
  waveform_plot = plot_waveform(waveform, sample_rate)
65
  spectrogram_plot = plot_spectrogram(waveform, sample_rate)
66
 
67
  return (
68
+ f"The voice is classified as '{new_label}' with a confidence of {confidence:.2f}%.",
69
  waveform_plot,
70
  spectrogram_plot
71
  )