Add new voices for Watson TTS (#48722)

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Mickaël Le Baillif 2021-05-16 11:12:05 +02:00 committed by GitHub
parent b84cf915f3
commit c2e2b046d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,6 @@
"""Support for IBM Watson TTS integration."""
import logging
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_watson import TextToSpeechV1
import voluptuous as vol
@ -6,6 +8,8 @@ import voluptuous as vol
from homeassistant.components.tts import PLATFORM_SCHEMA, Provider
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
CONF_URL = "watson_url"
CONF_APIKEY = "watson_apikey"
@ -18,22 +22,32 @@ CONF_TEXT_TYPE = "text"
# List from https://tinyurl.com/watson-tts-docs
SUPPORTED_VOICES = [
"ar-AR_OmarVoice",
"ar-MS_OmarVoice",
"de-DE_BirgitV2Voice",
"de-DE_BirgitV3Voice",
"de-DE_BirgitVoice",
"de-DE_DieterV2Voice",
"de-DE_DieterV3Voice",
"de-DE_DieterVoice",
"de-DE_ErikaV3Voice",
"en-AU_CraigVoice",
"en-AU_MadisonVoice",
"en-GB_KateV3Voice",
"en-GB_KateVoice",
"en-GB_CharlotteV3Voice",
"en-GB_JamesV3Voice",
"en-GB_KateV3Voice",
"en-GB_KateVoice",
"en-US_AllisonV2Voice",
"en-US_AllisonV3Voice",
"en-US_AllisonVoice",
"en-US_EmilyV3Voice",
"en-US_HenryV3Voice",
"en-US_KevinV3Voice",
"en-US_LisaV2Voice",
"en-US_LisaV3Voice",
"en-US_LisaVoice",
"en-US_MichaelV2Voice",
"en-US_MichaelV3Voice",
"en-US_MichaelVoice",
"en-US_OliviaV3Voice",
@ -45,12 +59,17 @@ SUPPORTED_VOICES = [
"es-LA_SofiaVoice",
"es-US_SofiaV3Voice",
"es-US_SofiaVoice",
"fr-CA_LouiseV3Voice",
"fr-FR_NicolasV3Voice",
"fr-FR_ReneeV3Voice",
"fr-FR_ReneeVoice",
"it-IT_FrancescaV2Voice",
"it-IT_FrancescaV3Voice",
"it-IT_FrancescaVoice",
"ja-JP_EmiV3Voice",
"ja-JP_EmiVoice",
"ko-KR_HyunjunVoice",
"ko-KR_SiWooVoice",
"ko-KR_YoungmiVoice",
"ko-KR_YunaVoice",
"nl-NL_EmmaVoice",
@ -62,6 +81,25 @@ SUPPORTED_VOICES = [
"zh-CN_ZhangJingVoice",
]
DEPRECATED_VOICES = [
"ar-AR_OmarVoice",
"de-DE_BirgitVoice",
"de-DE_DieterVoice",
"en-GB_KateVoice",
"en-GB_KateV3Voice",
"en-US_AllisonVoice",
"en-US_LisaVoice",
"en-US_MichaelVoice",
"es-ES_EnriqueVoice",
"es-ES_LauraVoice",
"es-LA_SofiaVoice",
"es-US_SofiaVoice",
"fr-FR_ReneeVoice",
"it-IT_FrancescaVoice",
"ja-JP_EmiVoice",
"pt-BR_IsabelaVoice",
]
SUPPORTED_OUTPUT_FORMATS = [
"audio/flac",
"audio/mp3",
@ -82,7 +120,7 @@ CONTENT_TYPE_EXTENSIONS = {
"audio/wav": "wav",
}
DEFAULT_VOICE = "en-US_AllisonVoice"
DEFAULT_VOICE = "en-US_AllisonV3Voice"
DEFAULT_OUTPUT_FORMAT = "audio/mp3"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
@ -124,6 +162,12 @@ class WatsonTTSProvider(Provider):
self.output_format = output_format
self.name = "Watson TTS"
if self.default_voice in DEPRECATED_VOICES:
_LOGGER.warning(
"Watson TTS voice %s is deprecated, it may be removed in the future",
self.default_voice,
)
@property
def supported_languages(self):
"""Return a list of supported languages."""