Spaces:
Building
Building
Update stt/stt_google.py
Browse files- stt/stt_google.py +21 -1
stt/stt_google.py
CHANGED
@@ -389,7 +389,22 @@ class GoogleCloudSTT(STTInterface):
|
|
389 |
|
390 |
# Create streaming client
|
391 |
log_info("🎤 Creating Google STT streaming client...")
|
392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
|
394 |
# Track if we've received any response
|
395 |
first_response_time = None
|
@@ -397,6 +412,11 @@ class GoogleCloudSTT(STTInterface):
|
|
397 |
|
398 |
# Process responses with detailed logging
|
399 |
for response in responses:
|
|
|
|
|
|
|
|
|
|
|
400 |
response_count += 1
|
401 |
|
402 |
if first_response_time is None:
|
|
|
389 |
|
390 |
# Create streaming client
|
391 |
log_info("🎤 Creating Google STT streaming client...")
|
392 |
+
|
393 |
+
# Set a timeout for the streaming call
|
394 |
+
import grpc
|
395 |
+
timeout = 300 # 5 minutes max for the stream
|
396 |
+
|
397 |
+
# Create streaming client with timeout
|
398 |
+
responses = self.client.streaming_recognize(
|
399 |
+
self.streaming_config,
|
400 |
+
requests,
|
401 |
+
timeout=timeout
|
402 |
+
)
|
403 |
+
|
404 |
+
# Set initial response timeout
|
405 |
+
initial_response_timeout = 30 # 30 seconds to get first response
|
406 |
+
stream_start = time.time()
|
407 |
+
got_first_response = False
|
408 |
|
409 |
# Track if we've received any response
|
410 |
first_response_time = None
|
|
|
412 |
|
413 |
# Process responses with detailed logging
|
414 |
for response in responses:
|
415 |
+
if not got_first_response:
|
416 |
+
got_first_response = True
|
417 |
+
elapsed = time.time() - stream_start
|
418 |
+
log_info(f"✅ Got first response from Google after {elapsed:.2f}s")
|
419 |
+
|
420 |
response_count += 1
|
421 |
|
422 |
if first_response_time is None:
|