本文整理汇总了Python中homeassistant.components.tts.PLATFORM_SCHEMA类的典型用法代码示例。如果您正苦于以下问题:Python PLATFORM_SCHEMA类的具体用法?Python PLATFORM_SCHEMA怎么用?Python PLATFORM_SCHEMA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PLATFORM_SCHEMA类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: async_get_engine
GOOGLE_SPEECH_URL = "http://translate.google.com/translate_tts"
MESSAGE_SIZE = 148
SUPPORT_LANGUAGES = [
'af', 'sq', 'ar', 'hy', 'bn', 'ca', 'zh', 'zh-cn', 'zh-tw', 'zh-yue',
'hr', 'cs', 'da', 'nl', 'en', 'en-au', 'en-uk', 'en-us', 'eo', 'fi',
'fr', 'de', 'el', 'hi', 'hu', 'is', 'id', 'it', 'ja', 'ko', 'la', 'lv',
'mk', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru', 'sr', 'sk', 'es', 'es-es',
'es-us', 'sw', 'sv', 'ta', 'th', 'tr', 'vi', 'cy',
]
DEFAULT_LANG = 'en'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_LANG, default=DEFAULT_LANG): vol.In(SUPPORT_LANGUAGES),
})
@asyncio.coroutine
def async_get_engine(hass, config):
"""Set up Google speech component."""
return GoogleProvider(hass, config[CONF_LANG])
class GoogleProvider(Provider):
"""The Google speech API provider."""
def __init__(self, hass, lang):
"""Init Google TTS service."""
self.hass = hass
示例2: async_get_engine
'ulaw_8khz_stereo', 'ulaw_11khz_mono', 'ulaw_11khz_stereo',
'ulaw_22khz_mono', 'ulaw_22khz_stereo', 'ulaw_44khz_mono',
'ulaw_44khz_stereo',
]
CONF_CODEC = 'codec'
CONF_FORMAT = 'format'
DEFAULT_LANG = 'en-us'
DEFAULT_CODEC = 'mp3'
DEFAULT_FORMAT = '8khz_8bit_mono'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string,
vol.Optional(CONF_LANG, default=DEFAULT_LANG): vol.In(SUPPORT_LANGUAGES),
vol.Optional(CONF_CODEC, default=DEFAULT_CODEC): vol.In(SUPPORT_CODECS),
vol.Optional(CONF_FORMAT, default=DEFAULT_FORMAT): vol.In(SUPPORT_FORMATS),
})
@asyncio.coroutine
def async_get_engine(hass, config):
"""Setup VoiceRSS speech component."""
return VoiceRSSProvider(hass, config)
class VoiceRSSProvider(Provider):
"""VoiceRSS speech api provider."""
def __init__(self, hass, conf):
"""Init VoiceRSS TTS service."""
示例3: async_get_engine
'aiff', 'au', 'wav'
]
CONF_VOICE = 'voice'
CONF_CODEC = 'codec'
DEFAULT_HOST = 'localhost'
DEFAULT_PORT = 59125
DEFAULT_LANG = 'en-US'
DEFAULT_VOICE = 'cmu-slt-hsmm'
DEFAULT_CODEC = 'wav'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_LANG, default=DEFAULT_LANG): vol.In(SUPPORT_LANGUAGES),
vol.Optional(CONF_VOICE, default=DEFAULT_VOICE): cv.string,
vol.Optional(CONF_CODEC, default=DEFAULT_CODEC): vol.In(SUPPORT_CODEC)
})
async def async_get_engine(hass, config):
"""Set up MaryTTS speech component."""
return MaryTTSProvider(hass, config)
class MaryTTSProvider(Provider):
"""MaryTTS speech api provider."""
def __init__(self, hass, conf):
"""Init MaryTTS TTS service."""
示例4: async_get_engine
CONF_CODEC = 'codec'
CONF_VOICE = 'voice'
CONF_EMOTION = 'emotion'
CONF_SPEED = 'speed'
DEFAULT_LANG = 'en-US'
DEFAULT_CODEC = 'mp3'
DEFAULT_VOICE = 'zahar'
DEFAULT_EMOTION = 'neutral'
DEFAULT_SPEED = 1
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string,
vol.Optional(CONF_LANG, default=DEFAULT_LANG): vol.In(SUPPORT_LANGUAGES),
vol.Optional(CONF_CODEC, default=DEFAULT_CODEC): vol.In(SUPPORT_CODECS),
vol.Optional(CONF_VOICE, default=DEFAULT_VOICE): vol.In(SUPPORT_VOICES),
vol.Optional(CONF_EMOTION, default=DEFAULT_EMOTION):
vol.In(SUPPORTED_EMOTION),
vol.Optional(CONF_SPEED, default=DEFAULT_SPEED):
vol.Range(min=MIN_SPEED, max=MAX_SPEED)
})
@asyncio.coroutine
def async_get_engine(hass, config):
"""Set up VoiceRSS speech component."""
return YandexSpeechKitProvider(hass, config)
class YandexSpeechKitProvider(Provider):
"""VoiceRSS speech api provider."""
示例5:
CONF_APP_ID = 'app_id'
CONF_SECRET_KEY = 'secret_key'
CONF_SPEED = 'speed'
CONF_PITCH = 'pitch'
CONF_VOLUME = 'volume'
CONF_PERSON = 'person'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_LANG, default=DEFAULT_LANG): vol.In(SUPPORTED_LANGUAGES),
vol.Required(CONF_APP_ID): cv.string,
vol.Required(CONF_API_KEY): cv.string,
vol.Required(CONF_SECRET_KEY): cv.string,
vol.Optional(CONF_SPEED, default=5): vol.All(
vol.Coerce(int), vol.Range(min=0, max=9)
),
vol.Optional(CONF_PITCH, default=5): vol.All(
vol.Coerce(int), vol.Range(min=0, max=9)
),
vol.Optional(CONF_VOLUME, default=5): vol.All(
vol.Coerce(int), vol.Range(min=0, max=15)
),
vol.Optional(CONF_PERSON, default=0): vol.All(
vol.Coerce(int), vol.Range(min=0, max=4)
),
})
# Keys are options in the config file, and Values are options
# required by Baidu TTS API.
_OPTIONS = {
CONF_PERSON: 'per',
CONF_PITCH: 'pit',
CONF_SPEED: 'spd',
示例6: get_engine
'pt-pt', 'ro-ro', 'ru-ru', 'sk-sk', 'sv-se', 'th-th', 'tr-tr', 'zh-cn',
'zh-hk', 'zh-tw',
]
GENDERS = [
'Female', 'Male',
]
DEFAULT_LANG = 'en-us'
DEFAULT_GENDER = 'Female'
DEFAULT_TYPE = 'ZiraRUS'
DEFAULT_OUTPUT = 'audio-16khz-128kbitrate-mono-mp3'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string,
vol.Optional(CONF_LANG, default=DEFAULT_LANG): vol.In(SUPPORTED_LANGUAGES),
vol.Optional(CONF_GENDER, default=DEFAULT_GENDER): vol.In(GENDERS),
vol.Optional(CONF_TYPE, default=DEFAULT_TYPE): cv.string,
})
def get_engine(hass, config):
"""Set up Microsoft speech component."""
return MicrosoftProvider(config[CONF_API_KEY], config[CONF_LANG],
config[CONF_GENDER], config[CONF_TYPE])
class MicrosoftProvider(Provider):
"""The Microsoft speech API provider."""
def __init__(self, apikey, lang, gender, ttype):
"""Init Microsoft TTS service."""
示例7: get_engine
DEFAULT_OUTPUT_FORMAT = 'mp3'
DEFAULT_TEXT_TYPE = 'text'
DEFAULT_SAMPLE_RATES = {
'mp3': '22050',
'ogg_vorbis': '22050',
'pcm': '16000'
}
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_REGION, default=DEFAULT_REGION):
vol.In(SUPPORTED_REGIONS),
vol.Inclusive(CONF_ACCESS_KEY_ID, ATTR_CREDENTIALS): cv.string,
vol.Inclusive(CONF_SECRET_ACCESS_KEY, ATTR_CREDENTIALS): cv.string,
vol.Exclusive(CONF_PROFILE_NAME, ATTR_CREDENTIALS): cv.string,
vol.Optional(CONF_VOICE, default=DEFAULT_VOICE): vol.In(SUPPORTED_VOICES),
vol.Optional(CONF_OUTPUT_FORMAT, default=DEFAULT_OUTPUT_FORMAT):
vol.In(SUPPORTED_OUTPUT_FORMATS),
vol.Optional(CONF_SAMPLE_RATE): vol.All(cv.string,
vol.In(SUPPORTED_SAMPLE_RATES)),
vol.Optional(CONF_TEXT_TYPE, default=DEFAULT_TEXT_TYPE):
vol.In(SUPPORTED_TEXT_TYPES),
})
def get_engine(hass, config):
"""Set up Amazon Polly speech component."""
# pylint: disable=import-error
output_format = config.get(CONF_OUTPUT_FORMAT)
sample_rate = config.get(CONF_SAMPLE_RATE,
DEFAULT_SAMPLE_RATES[output_format])
if sample_rate not in SUPPORTED_SAMPLE_RATES_MAP.get(output_format):
示例8: get_engine
DEFAULT_LANG = 'en-us'
DEFAULT_GENDER = 'Female'
DEFAULT_TYPE = 'ZiraRUS'
DEFAULT_OUTPUT = 'audio-16khz-128kbitrate-mono-mp3'
DEFAULT_RATE = 0
DEFAULT_VOLUME = 0
DEFAULT_PITCH = "default"
DEFAULT_CONTOUR = ""
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string,
vol.Optional(CONF_LANG, default=DEFAULT_LANG): vol.In(SUPPORTED_LANGUAGES),
vol.Optional(CONF_GENDER, default=DEFAULT_GENDER): vol.In(GENDERS),
vol.Optional(CONF_TYPE, default=DEFAULT_TYPE): cv.string,
vol.Optional(CONF_RATE, default=DEFAULT_RATE):
vol.All(vol.Coerce(int), vol.Range(-100, 100)),
vol.Optional(CONF_VOLUME, default=DEFAULT_VOLUME):
vol.All(vol.Coerce(int), vol.Range(-100, 100)),
vol.Optional(CONF_PITCH, default=DEFAULT_PITCH): cv.string,
vol.Optional(CONF_CONTOUR, default=DEFAULT_CONTOUR): cv.string,
})
def get_engine(hass, config):
"""Set up Microsoft speech component."""
return MicrosoftProvider(config[CONF_API_KEY], config[CONF_LANG],
config[CONF_GENDER], config[CONF_TYPE],
config[CONF_RATE], config[CONF_VOLUME],
config[CONF_PITCH], config[CONF_CONTOUR])
示例9: get_engine
CONF_APIKEY = 'api_key'
CONF_SECRETKEY = 'secret_key'
CONF_SPEED = 'speed'
CONF_PITCH = 'pitch'
CONF_VOLUME = 'volume'
PERSON = 'person'
TOKEN_INTERFACE = 'https://openapi.baidu.com/oauth/2.0/token'
TEXT2AUDIO_INTERFACE = 'http://tsn.baidu.com/text2audio'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_LANG, default=DEFAULT_LANG): vol.In(SUPPORT_LANGUAGES),
vol.Optional(CONF_APIKEY): cv.string,
vol.Optional(CONF_SECRETKEY):cv.string,
vol.Optional(CONF_SPEED,default='5'): cv.string,
vol.Optional(CONF_PITCH,default='5'): cv.string,
vol.Optional(CONF_VOLUME,default='5'): cv.string,
vol.Optional(PERSON,default='0'): cv.string,
})
def get_engine(hass, config):
lang = config.get(CONF_LANG)
apiKey = config.get(CONF_APIKEY)
secretKey = config.get(CONF_SECRETKEY)
speed = config.get(CONF_SPEED)
pitch = config.get(CONF_PITCH)
volume = config.get(CONF_VOLUME)
person = config.get(PERSON)
if apiKey == None: