mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Retry Google Cloud exceptions (#141266)
This commit is contained in:
parent
0f60fd8c40
commit
4e6eecf11b
@ -6,6 +6,7 @@ from collections.abc import AsyncGenerator, AsyncIterable
|
||||
import logging
|
||||
|
||||
from google.api_core.exceptions import GoogleAPIError, Unauthenticated
|
||||
from google.api_core.retry import AsyncRetry
|
||||
from google.cloud import speech_v1
|
||||
|
||||
from homeassistant.components.stt import (
|
||||
@ -127,6 +128,7 @@ class GoogleCloudSpeechToTextEntity(SpeechToTextEntity):
|
||||
responses = await self._client.streaming_recognize(
|
||||
requests=request_generator(),
|
||||
timeout=10,
|
||||
retry=AsyncRetry(initial=0.1, maximum=2.0, multiplier=2.0),
|
||||
)
|
||||
|
||||
transcript = ""
|
||||
|
@ -7,6 +7,7 @@ from pathlib import Path
|
||||
from typing import Any, cast
|
||||
|
||||
from google.api_core.exceptions import GoogleAPIError, Unauthenticated
|
||||
from google.api_core.retry import AsyncRetry
|
||||
from google.cloud import texttospeech
|
||||
import voluptuous as vol
|
||||
|
||||
@ -215,7 +216,11 @@ class BaseGoogleCloudProvider:
|
||||
),
|
||||
)
|
||||
|
||||
response = await self._client.synthesize_speech(request, timeout=10)
|
||||
response = await self._client.synthesize_speech(
|
||||
request,
|
||||
timeout=10,
|
||||
retry=AsyncRetry(initial=0.1, maximum=2.0, multiplier=2.0),
|
||||
)
|
||||
|
||||
if encoding == texttospeech.AudioEncoding.MP3:
|
||||
extension = "mp3"
|
||||
|
Loading…
x
Reference in New Issue
Block a user