Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,6 +58,14 @@ def transcribe_audio_online_streaming(file, language):
|
|
| 58 |
sample_rate = 16000
|
| 59 |
|
| 60 |
waveform_np = waveform.numpy()[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
total_samples = waveform_np.shape[0]
|
| 62 |
|
| 63 |
s = recognizer.create_stream()
|
|
|
|
| 58 |
sample_rate = 16000
|
| 59 |
|
| 60 |
waveform_np = waveform.numpy()[0]
|
| 61 |
+
|
| 62 |
+
# Add 0.5 seconds of silence padding at the beginning and end
|
| 63 |
+
pad_duration = 0.5 # seconds
|
| 64 |
+
pad_samples = int(pad_duration * sample_rate)
|
| 65 |
+
pad_start = np.zeros(pad_samples, dtype=np.float32)
|
| 66 |
+
pad_end = np.zeros(pad_samples, dtype=np.float32)
|
| 67 |
+
waveform_np = np.concatenate([pad_start, waveform_np, pad_end])
|
| 68 |
+
|
| 69 |
total_samples = waveform_np.shape[0]
|
| 70 |
|
| 71 |
s = recognizer.create_stream()
|