Spaces:
Building
Building
Update stt/stt_deepgram.py
Browse files- stt/stt_deepgram.py +26 -11
stt/stt_deepgram.py
CHANGED
@@ -178,7 +178,7 @@ class DeepgramSTT(STTInterface):
|
|
178 |
if not result:
|
179 |
log_warning("⚠️ No result in transcript event")
|
180 |
return
|
181 |
-
|
182 |
# ✅ Debug için result objesini detaylı inceleyin
|
183 |
if self.total_chunks < 5: # İlk birkaç event için
|
184 |
log_debug(f"🔍 Result object type: {type(result)}")
|
@@ -190,7 +190,7 @@ class DeepgramSTT(STTInterface):
|
|
190 |
log_debug(f"🔍 Result dict: {result.__dict__}")
|
191 |
except:
|
192 |
pass
|
193 |
-
|
194 |
# Access properties directly from the result object
|
195 |
is_final = result.is_final if hasattr(result, 'is_final') else False
|
196 |
|
@@ -204,27 +204,42 @@ class DeepgramSTT(STTInterface):
|
|
204 |
# Log all transcripts for debugging
|
205 |
log_debug(f"📝 Raw transcript: '{transcript}' (is_final: {is_final}, confidence: {confidence})")
|
206 |
|
207 |
-
|
|
|
|
|
208 |
transcription_result = TranscriptionResult(
|
209 |
-
text=transcript,
|
210 |
is_final=is_final,
|
211 |
confidence=confidence,
|
212 |
timestamp=datetime.now().timestamp()
|
213 |
)
|
214 |
|
215 |
-
# Queue result
|
216 |
try:
|
217 |
self.responses_queue.put(transcription_result)
|
218 |
-
|
219 |
-
|
|
|
220 |
log_info(f"🎯 FINAL TRANSCRIPT: '{transcript}' (confidence: {confidence:.2f})")
|
221 |
else:
|
222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
except queue.Full:
|
224 |
log_warning("⚠️ Response queue full")
|
225 |
-
else:
|
226 |
-
if is_final:
|
227 |
-
log_warning(f"⚠️ Empty final transcript received")
|
228 |
|
229 |
except Exception as e:
|
230 |
log_error(f"❌ Error processing transcript: {e}")
|
|
|
178 |
if not result:
|
179 |
log_warning("⚠️ No result in transcript event")
|
180 |
return
|
181 |
+
|
182 |
# ✅ Debug için result objesini detaylı inceleyin
|
183 |
if self.total_chunks < 5: # İlk birkaç event için
|
184 |
log_debug(f"🔍 Result object type: {type(result)}")
|
|
|
190 |
log_debug(f"🔍 Result dict: {result.__dict__}")
|
191 |
except:
|
192 |
pass
|
193 |
+
|
194 |
# Access properties directly from the result object
|
195 |
is_final = result.is_final if hasattr(result, 'is_final') else False
|
196 |
|
|
|
204 |
# Log all transcripts for debugging
|
205 |
log_debug(f"📝 Raw transcript: '{transcript}' (is_final: {is_final}, confidence: {confidence})")
|
206 |
|
207 |
+
# ✅ ÖNEMLİ DEĞİŞİKLİK: Final result'ları boş olsa bile kabul et
|
208 |
+
if is_final:
|
209 |
+
# Final transcript - boş olabilir ama yine de işle
|
210 |
transcription_result = TranscriptionResult(
|
211 |
+
text=transcript or "", # Boş string olabilir
|
212 |
is_final=is_final,
|
213 |
confidence=confidence,
|
214 |
timestamp=datetime.now().timestamp()
|
215 |
)
|
216 |
|
|
|
217 |
try:
|
218 |
self.responses_queue.put(transcription_result)
|
219 |
+
self.final_result_received = True
|
220 |
+
|
221 |
+
if transcript and transcript.strip():
|
222 |
log_info(f"🎯 FINAL TRANSCRIPT: '{transcript}' (confidence: {confidence:.2f})")
|
223 |
else:
|
224 |
+
log_warning(f"⚠️ Empty final transcript received - but queued for state change")
|
225 |
+
|
226 |
+
except queue.Full:
|
227 |
+
log_warning("⚠️ Response queue full")
|
228 |
+
|
229 |
+
elif transcript and transcript.strip():
|
230 |
+
# Interim result - sadece dolu olanları kabul et
|
231 |
+
transcription_result = TranscriptionResult(
|
232 |
+
text=transcript,
|
233 |
+
is_final=is_final,
|
234 |
+
confidence=confidence,
|
235 |
+
timestamp=datetime.now().timestamp()
|
236 |
+
)
|
237 |
+
|
238 |
+
try:
|
239 |
+
self.responses_queue.put(transcription_result)
|
240 |
+
log_info(f"📝 Interim transcript: '{transcript}'")
|
241 |
except queue.Full:
|
242 |
log_warning("⚠️ Response queue full")
|
|
|
|
|
|
|
243 |
|
244 |
except Exception as e:
|
245 |
log_error(f"❌ Error processing transcript: {e}")
|