Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -24,14 +24,17 @@ def transcribe(inputs, previous_transcription):
|
|
24 |
try:
|
25 |
sample_rate, audio_data = inputs
|
26 |
|
27 |
-
# Convert audio data to a NumPy array
|
28 |
-
audio_data = np.frombuffer(audio_data, dtype=np.int16)
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
35 |
|
36 |
return previous_transcription
|
37 |
except Exception as e:
|
|
|
24 |
try:
|
25 |
sample_rate, audio_data = inputs
|
26 |
|
27 |
+
# Convert audio data to a NumPy array of floats normalized between -1 and 1
|
28 |
+
audio_data = np.frombuffer(audio_data, dtype=np.int16).astype(np.float32) / 32768.0
|
29 |
+
|
30 |
+
# Perform transcription
|
31 |
+
transcription = pipe(audio_data,
|
32 |
+
batch_size=BATCH_SIZE,
|
33 |
+
generate_kwargs={"task": "transcribe"},
|
34 |
+
return_timestamps=True)
|
35 |
+
|
36 |
+
# Append new transcription to previous transcription
|
37 |
+
previous_transcription += transcription["text"]
|
38 |
|
39 |
return previous_transcription
|
40 |
except Exception as e:
|