mirror of
https://github.com/elisspace/core.git
synced 2026-09-29 05:49:53 +00:00
Fix exception handling in Microsoft TTS (#92556)
pycsspeechtts uses the requests library, but Microsoft TTS previously caught HTTPException from the standard library. This is changed to catch requests.HTTPError and return `(None, None)` consistent with other TTS integrations. This will properly raise HomeAssistantError for display in the frontend. Follow up to PR #92215 which adds tests for Microsoft TTS.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"""Support for the Microsoft Cognitive Services text-to-speech service."""
|
||||
from http.client import HTTPException
|
||||
import logging
|
||||
|
||||
from pycsspeechtts import pycsspeechtts
|
||||
from requests.exceptions import HTTPError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.tts import CONF_LANG, PLATFORM_SCHEMA, Provider
|
||||
@@ -121,7 +121,7 @@ class MicrosoftProvider(Provider):
|
||||
contour=self._contour,
|
||||
text=message,
|
||||
)
|
||||
except HTTPException as ex:
|
||||
except HTTPError as ex:
|
||||
_LOGGER.error("Error occurred for Microsoft TTS: %s", ex)
|
||||
return (None, None)
|
||||
return ("mp3", data)
|
||||
|
||||
Reference in New Issue
Block a user