Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
42 |
-
|
|
|
43 |
|
44 |
if stream is not None:
|
45 |
-
stream = np.concatenate([stream,
|
46 |
else:
|
47 |
-
stream =
|
48 |
|
49 |
-
transcription = pipe({"sampling_rate":
|
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 |
|