mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +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
|
import logging
|
||||||
|
|
||||||
from google.api_core.exceptions import GoogleAPIError, Unauthenticated
|
from google.api_core.exceptions import GoogleAPIError, Unauthenticated
|
||||||
|
from google.api_core.retry import AsyncRetry
|
||||||
from google.cloud import speech_v1
|
from google.cloud import speech_v1
|
||||||
|
|
||||||
from homeassistant.components.stt import (
|
from homeassistant.components.stt import (
|
||||||
@ -127,6 +128,7 @@ class GoogleCloudSpeechToTextEntity(SpeechToTextEntity):
|
|||||||
responses = await self._client.streaming_recognize(
|
responses = await self._client.streaming_recognize(
|
||||||
requests=request_generator(),
|
requests=request_generator(),
|
||||||
timeout=10,
|
timeout=10,
|
||||||
|
retry=AsyncRetry(initial=0.1, maximum=2.0, multiplier=2.0),
|
||||||
)
|
)
|
||||||
|
|
||||||
transcript = ""
|
transcript = ""
|
||||||
|
@ -7,6 +7,7 @@ from pathlib import Path
|
|||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from google.api_core.exceptions import GoogleAPIError, Unauthenticated
|
from google.api_core.exceptions import GoogleAPIError, Unauthenticated
|
||||||
|
from google.api_core.retry import AsyncRetry
|
||||||
from google.cloud import texttospeech
|
from google.cloud import texttospeech
|
||||||
import voluptuous as vol
|
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:
|
if encoding == texttospeech.AudioEncoding.MP3:
|
||||||
extension = "mp3"
|
extension = "mp3"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user