* TTS Component / Google speech platform * Change file backend handling / cache * Use mimetype / rename Provider function / allow cache on service call * Add a memcache for faster response * Add demo platform * First version of unittest * Address comments * improve error handling / address comments * Add google unittest & check http response code * Change url param handling * add test for other language * Change hash to sha256 for same hash on every os/hardware * add unittest for receive demo data * add test for error cases * Test case load from file to mem over aiohttp server * Use cache SpeechManager level, address other comments * Add service for clear cache * Update service.yaml * add support for spliting google message
29 lines
705 B
Python
29 lines
705 B
Python
"""
|
|
Support for the demo speech service.
|
|
|
|
For more details about this component, please refer to the documentation at
|
|
https://home-assistant.io/components/demo/
|
|
"""
|
|
import os
|
|
|
|
from homeassistant.components.tts import Provider
|
|
|
|
|
|
def get_engine(hass, config):
|
|
"""Setup Demo speech component."""
|
|
return DemoProvider()
|
|
|
|
|
|
class DemoProvider(Provider):
|
|
"""Demo speech api provider."""
|
|
|
|
def get_tts_audio(self, message):
|
|
"""Load TTS from demo."""
|
|
filename = os.path.join(os.path.dirname(__file__), "demo.mp3")
|
|
try:
|
|
with open(filename, 'rb') as voice:
|
|
data = voice.read()
|
|
except OSError:
|
|
return
|
|
|
|
return ("mp3", data)
|