GoogleSTTService: Add more robust handling of 409 errors
This commit is contained in:
@@ -73,6 +73,13 @@ reason")`.
|
|||||||
level. Important: The STTMuteFilter should be placed _after_ the STT service
|
level. Important: The STTMuteFilter should be placed _after_ the STT service
|
||||||
itself.
|
itself.
|
||||||
|
|
||||||
|
- Improved `GoogleSTTService` error handling to properly catch gRPC `Aborted`
|
||||||
|
exceptions (corresponding to 409 errors) caused by stream inactivity. These
|
||||||
|
exceptions are now logged at DEBUG level instead of ERROR level, since they
|
||||||
|
indicate expected behavior when no audio is sent for 10+ seconds (e.g., during
|
||||||
|
long silences or when audio input is blocked). The service automatically
|
||||||
|
reconnects when this occurs.
|
||||||
|
|
||||||
- Bumped the `fastapi` dependency's upperbound to `<0.122.0`.
|
- Bumped the `fastapi` dependency's upperbound to `<0.122.0`.
|
||||||
|
|
||||||
- Updated the default model for `GoogleVertexLLMService` to `gemini-2.5-flash`.
|
- Updated the default model for `GoogleVertexLLMService` to `gemini-2.5-flash`.
|
||||||
|
|||||||
@@ -61,8 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Starting bot")
|
logger.info(f"Starting bot")
|
||||||
|
|
||||||
stt = GoogleSTTService(
|
stt = GoogleSTTService(
|
||||||
params=GoogleSTTService.InputParams(languages=Language.EN_US),
|
params=GoogleSTTService.InputParams(languages=Language.EN_US, model="chirp_3"),
|
||||||
credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"),
|
credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"),
|
||||||
|
location="us",
|
||||||
)
|
)
|
||||||
|
|
||||||
tts = GoogleTTSService(
|
tts = GoogleTTSService(
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ from pipecat.utils.time import time_now_iso8601
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from google.api_core.client_options import ClientOptions
|
from google.api_core.client_options import ClientOptions
|
||||||
|
from google.api_core.exceptions import Aborted
|
||||||
from google.auth import default
|
from google.auth import default
|
||||||
from google.auth.exceptions import GoogleAuthError
|
from google.auth.exceptions import GoogleAuthError
|
||||||
from google.cloud import speech_v2
|
from google.cloud import speech_v2
|
||||||
@@ -886,6 +887,18 @@ class GoogleSTTService(STTService):
|
|||||||
result=result,
|
result=result,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
except Aborted as e:
|
||||||
|
# Handle stream abort due to inactivity (409 error).
|
||||||
|
# This occurs when no audio is sent to the stream for 10+ seconds,
|
||||||
|
# which can happen when InputAudioRawFrames are blocked (e.g., by STTMuteFilter).
|
||||||
|
# Google's STT service automatically closes the stream in this case.
|
||||||
|
# We log at DEBUG level (not ERROR) since this is recoverable, then re-raise
|
||||||
|
# to trigger automatic reconnection in _stream_audio.
|
||||||
|
logger.debug(
|
||||||
|
f"{self} Stream aborted due to inactivity (no audio input). "
|
||||||
|
f"Reconnecting automatically..."
|
||||||
|
)
|
||||||
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error processing Google STT responses: {e}")
|
logger.error(f"Error processing Google STT responses: {e}")
|
||||||
# Re-raise the exception to let it propagate (e.g. in the case of a
|
# Re-raise the exception to let it propagate (e.g. in the case of a
|
||||||
|
|||||||
Reference in New Issue
Block a user