tahirsher commited on
Commit
add50b3
·
verified ·
1 Parent(s): 8d19597

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -81,14 +81,20 @@ if audio_file:
81
  adversarial_waveform = torch.clamp(adversarial_waveform, -1.0, 1.0)
82
 
83
  # ================================
84
- # ✅ Fast Transcription Processing with Conformer
85
  # ================================
86
- input_features = processor(adversarial_waveform.squeeze().numpy(), sampling_rate=16000, return_tensors="pt").input_features.to("cuda" if torch.cuda.is_available() else "cpu")
87
-
88
  # Ensure the input has batch dimension (even if it's one example)
89
- if len(input_features.shape) == 1:
90
- input_features = input_features.unsqueeze(0)
 
 
 
91
 
 
 
 
92
  with torch.no_grad():
93
  logits = model(input_features).logits
94
 
 
81
  adversarial_waveform = torch.clamp(adversarial_waveform, -1.0, 1.0)
82
 
83
  # ================================
84
+ # ✅ Preprocess Audio with Processor (Corrected)
85
  # ================================
86
+ inputs = processor(adversarial_waveform.squeeze().numpy(), sampling_rate=16000, return_tensors="pt", padding=True)
87
+
88
  # Ensure the input has batch dimension (even if it's one example)
89
+ if len(inputs.input_features.shape) == 1:
90
+ inputs.input_features = inputs.input_features.unsqueeze(0)
91
+
92
+ # Move the input features to the correct device (GPU/CPU)
93
+ input_features = inputs.input_features.to("cuda" if torch.cuda.is_available() else "cpu")
94
 
95
+ # ================================
96
+ # ✅ Fast Transcription Processing with Conformer
97
+ # ================================
98
  with torch.no_grad():
99
  logits = model(input_features).logits
100