Update app.py
Browse files
app.py
CHANGED
@@ -81,14 +81,20 @@ if audio_file:
|
|
81 |
adversarial_waveform = torch.clamp(adversarial_waveform, -1.0, 1.0)
|
82 |
|
83 |
# ================================
|
84 |
-
# ✅
|
85 |
# ================================
|
86 |
-
|
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 |
|