Spaces:
Paused
Paused
Update stt/stt_deepgram.py
Browse files- stt/stt_deepgram.py +12 -20
stt/stt_deepgram.py
CHANGED
|
@@ -289,19 +289,17 @@ class DeepgramSTT(STTInterface):
|
|
| 289 |
except:
|
| 290 |
log_warning("⚠️ Could not parse as Linear16")
|
| 291 |
|
| 292 |
-
#
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
if self.total_chunks % 50 == 0:
|
| 302 |
-
log_debug(f"📊 Listening... {self.total_chunks} chunks, {self.total_audio_bytes/1024:.1f}KB")
|
| 303 |
|
| 304 |
-
#
|
| 305 |
while True:
|
| 306 |
try:
|
| 307 |
result = self.responses_queue.get_nowait()
|
|
@@ -309,13 +307,7 @@ class DeepgramSTT(STTInterface):
|
|
| 309 |
# Log for debugging
|
| 310 |
log_debug(f"🎯 Yielding result: is_final={result.is_final}, text='{result.text}'")
|
| 311 |
|
| 312 |
-
|
| 313 |
-
self.final_result_received = True
|
| 314 |
-
yield result # ✅ Final result'ı yield et
|
| 315 |
-
# Artık yeni audio kabul etme
|
| 316 |
-
elif not self.final_result_received:
|
| 317 |
-
# Final gelmeden önce interim'leri yield et
|
| 318 |
-
yield result
|
| 319 |
|
| 320 |
except queue.Empty:
|
| 321 |
break
|
|
@@ -324,7 +316,7 @@ class DeepgramSTT(STTInterface):
|
|
| 324 |
log_error(f"❌ Error streaming audio", error=str(e))
|
| 325 |
self.is_streaming = False
|
| 326 |
raise
|
| 327 |
-
|
| 328 |
async def stop_streaming(self) -> Optional[TranscriptionResult]:
|
| 329 |
"""Stop streaming and clean up"""
|
| 330 |
if not self.is_streaming:
|
|
|
|
| 289 |
except:
|
| 290 |
log_warning("⚠️ Could not parse as Linear16")
|
| 291 |
|
| 292 |
+
# Send audio to Deepgram (final result gelse bile gönder, Deepgram kendi handle edecek)
|
| 293 |
+
self.live_connection.send(audio_chunk)
|
| 294 |
+
|
| 295 |
+
self.total_chunks += 1
|
| 296 |
+
self.total_audio_bytes += len(audio_chunk)
|
| 297 |
+
|
| 298 |
+
# Log progress
|
| 299 |
+
if self.total_chunks % 50 == 0:
|
| 300 |
+
log_debug(f"📊 Listening... {self.total_chunks} chunks, {self.total_audio_bytes/1024:.1f}KB")
|
|
|
|
|
|
|
| 301 |
|
| 302 |
+
# Check queue for results
|
| 303 |
while True:
|
| 304 |
try:
|
| 305 |
result = self.responses_queue.get_nowait()
|
|
|
|
| 307 |
# Log for debugging
|
| 308 |
log_debug(f"🎯 Yielding result: is_final={result.is_final}, text='{result.text}'")
|
| 309 |
|
| 310 |
+
yield result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
|
| 312 |
except queue.Empty:
|
| 313 |
break
|
|
|
|
| 316 |
log_error(f"❌ Error streaming audio", error=str(e))
|
| 317 |
self.is_streaming = False
|
| 318 |
raise
|
| 319 |
+
|
| 320 |
async def stop_streaming(self) -> Optional[TranscriptionResult]:
|
| 321 |
"""Stop streaming and clean up"""
|
| 322 |
if not self.is_streaming:
|