Spaces:
Sleeping
Sleeping
AshDavid12
commited on
Commit
·
1ad41b2
1
Parent(s):
a9516a4
fix if
Browse files
infer.py
CHANGED
@@ -142,7 +142,6 @@ async def process_audio_stream(websocket: WebSocket):
|
|
142 |
"""Continuously receive audio chunks and initiate transcription tasks."""
|
143 |
sampling_rate = 16000
|
144 |
min_chunk_size = 5 # in seconds
|
145 |
-
audio_buffer = np.array([], dtype=np.float32)
|
146 |
|
147 |
transcription_task = None
|
148 |
chunk_counter = 0
|
@@ -163,13 +162,12 @@ async def process_audio_stream(websocket: WebSocket):
|
|
163 |
audio_chunk = process_received_audio(data)
|
164 |
#logger.debug(f"Processed audio chunk {chunk_counter}: {len(audio_chunk)} samples")
|
165 |
# Check if enough audio has been buffered
|
166 |
-
if
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
)
|
173 |
|
174 |
#logger.debug(f"Audio buffer size: {len(audio_buffer)} samples")
|
175 |
except Exception as e:
|
|
|
142 |
"""Continuously receive audio chunks and initiate transcription tasks."""
|
143 |
sampling_rate = 16000
|
144 |
min_chunk_size = 5 # in seconds
|
|
|
145 |
|
146 |
transcription_task = None
|
147 |
chunk_counter = 0
|
|
|
162 |
audio_chunk = process_received_audio(data)
|
163 |
#logger.debug(f"Processed audio chunk {chunk_counter}: {len(audio_chunk)} samples")
|
164 |
# Check if enough audio has been buffered
|
165 |
+
if transcription_task is None or transcription_task.done():
|
166 |
+
# Start a new transcription task
|
167 |
+
# logger.info(f"Starting transcription task for {len(audio_buffer)} samples")
|
168 |
+
transcription_task = asyncio.create_task(
|
169 |
+
transcribe_and_send(websocket, audio_chunk)
|
170 |
+
)
|
|
|
171 |
|
172 |
#logger.debug(f"Audio buffer size: {len(audio_buffer)} samples")
|
173 |
except Exception as e:
|