Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add offline tts using pico #5005

Merged
merged 9 commits into from
Jan 4, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update picotts.py
  • Loading branch information
doudz authored Jan 3, 2017
commit e5623fce17a822d204965ea80d0423e952d8164b
10 changes: 6 additions & 4 deletions homeassistant/components/tts/picotts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Support for the picotts speech service.
For more information see...

For more details about this component, please refer to the documentation at
https://home-assistant.io/components/tts/picotts/
"""
import os
import tempfile
Expand Down Expand Up @@ -35,16 +37,16 @@ class PicoProvider(Provider):

def get_tts_audio(self, message):
"""Load TTS."""
with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as f:
fname = f.name
with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as fp:
fname = fp.name
cmd = ['pico2wave', '--wave', fname, '-l', self.language, message]
subprocess.call(cmd)
data = None
try:
with open(fname, 'rb') as voice:
data = voice.read()
except OSError:
_LOGGER.error("Error trying to read %s",fname)
_LOGGER.error("Error trying to read %s", fname)
return (None, None)
finally:
os.remove(fname)
Expand Down