| 1 |
"""This module provides voice API functionalities.""" |
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
from typing import TypedDict |
| 6 |
|
| 7 |
from .api import ApiBase, CloudApiError, api_exception_handler |
| 8 |
|
| 9 |
|
| 10 |
class VoiceApiError(CloudApiError): |
| 11 |
"""Exception raised when handling voice API.""" |
| 12 |
|
| 13 |
|
| 14 |
class VoiceConnectionDetails(TypedDict): |
| 15 |
"""Voice connection details from voice API.""" |
| 16 |
|
| 17 |
authorized_key: str |
| 18 |
endpoint_stt: str |
| 19 |
endpoint_tts: str |
| 20 |
valid: str |
| 21 |
|
| 22 |
|
| 23 |
class VoiceApi(ApiBase): |
| 24 |
"""Class to help communicate with the voice API.""" |
| 25 |
|
| 26 |
@api_exception_handler(VoiceApiError) |
| 27 |
async def connection_details(self) -> VoiceConnectionDetails: |
| 28 |
"""Get the voice connection details.""" |
| 29 |
details: VoiceConnectionDetails = await self._call_cloud_api( |
| 30 |
action="voice_connection_details" |
| 31 |
) |
| 32 |
return details |