KingNish commited on
Commit
2bf1d0a
·
verified ·
1 Parent(s): 8c4d38d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
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
- previous_transcription += pipe(audio_data,
31
- batch_size=BATCH_SIZE,
32
- generate_kwargs={"task": "transcribe"},
33
- return_timestamps=True,
34
- sampling_rate=sample_rate)["text"]
 
 
 
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: