anzorq commited on
Commit
8e25cf3
·
verified ·
1 Parent(s): d1e3f48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -38,15 +38,16 @@ def transcribe_streaming(stream, new_chunk):
38
  if new_chunk is None: # Handle the NoneType error for microphone input
39
  return "No audio received.", ""
40
 
41
- new_chunk = new_chunk.astype(np.float32)
42
- new_chunk /= np.max(np.abs(new_chunk))
 
43
 
44
  if stream is not None:
45
- stream = np.concatenate([stream, new_chunk])
46
  else:
47
- stream = new_chunk
48
 
49
- transcription = pipe({"sampling_rate": 16000, "raw": stream})['text']
50
 
51
  return stream, replace_symbols_back(transcription)
52
 
 
38
  if new_chunk is None: # Handle the NoneType error for microphone input
39
  return "No audio received.", ""
40
 
41
+ sampling_rate, audio_data = new_chunk
42
+ audio_data = audio_data.astype(np.float32)
43
+ audio_data /= np.max(np.abs(audio_data))
44
 
45
  if stream is not None:
46
+ stream = np.concatenate([stream, audio_data])
47
  else:
48
+ stream = audio_data
49
 
50
+ transcription = pipe({"sampling_rate": sampling_rate, "raw": stream})['text']
51
 
52
  return stream, replace_symbols_back(transcription)
53