Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -137,7 +137,16 @@ if audio:
|
|
| 137 |
# Debug: show duration
|
| 138 |
st.write("🎵 Audio duration (sec):", round(sound.duration_seconds, 2))
|
| 139 |
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
predicted_ids = model.generate(
|
| 143 |
input_features,
|
|
|
|
| 137 |
# Debug: show duration
|
| 138 |
st.write("🎵 Audio duration (sec):", round(sound.duration_seconds, 2))
|
| 139 |
|
| 140 |
+
samples = np.array(sound.get_array_of_samples()).astype(np.float32) / 32768.0
|
| 141 |
+
waveform = torch.tensor(samples).unsqueeze(0) # shape: (1, T)
|
| 142 |
+
sr = 16000 # since we resampled
|
| 143 |
+
|
| 144 |
+
# Whisper preprocessing
|
| 145 |
+
input_features = processor(
|
| 146 |
+
waveform.squeeze(),
|
| 147 |
+
sampling_rate=sr,
|
| 148 |
+
return_tensors="pt"
|
| 149 |
+
).input_features
|
| 150 |
|
| 151 |
predicted_ids = model.generate(
|
| 152 |
input_features,
|