2016-05-26 16:16:13 +00:00
|
|
|
# Copyright 2016 Mycroft AI, Inc.
|
|
|
|
#
|
|
|
|
# This file is part of Mycroft Core.
|
|
|
|
#
|
|
|
|
# Mycroft Core is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Mycroft Core is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
2016-05-20 14:16:01 +00:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
from mycroft.tts import TTS, TTSValidator
|
|
|
|
|
2016-09-16 18:12:43 +00:00
|
|
|
__author__ = 'seanfitz', 'jdorleans'
|
2016-05-20 14:16:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ESpeak(TTS):
|
|
|
|
def __init__(self, lang, voice):
|
2016-09-16 18:12:43 +00:00
|
|
|
super(ESpeak, self).__init__(lang, voice, ESpeakValidator(self))
|
2016-05-20 14:16:01 +00:00
|
|
|
|
2016-09-17 02:08:53 +00:00
|
|
|
def execute(self, sentence):
|
2017-07-06 21:02:40 +00:00
|
|
|
self.begin_audio()
|
2016-05-20 22:15:53 +00:00
|
|
|
subprocess.call(
|
|
|
|
['espeak', '-v', self.lang + '+' + self.voice, sentence])
|
2017-07-06 21:02:40 +00:00
|
|
|
self.end_audio()
|
2016-05-20 14:16:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ESpeakValidator(TTSValidator):
|
2016-09-16 18:12:43 +00:00
|
|
|
def __init__(self, tts):
|
|
|
|
super(ESpeakValidator, self).__init__(tts)
|
2016-05-20 14:16:01 +00:00
|
|
|
|
2016-09-16 18:12:43 +00:00
|
|
|
def validate_lang(self):
|
2016-05-20 14:16:01 +00:00
|
|
|
# TODO
|
|
|
|
pass
|
|
|
|
|
2016-09-16 18:12:43 +00:00
|
|
|
def validate_connection(self):
|
2016-05-20 14:16:01 +00:00
|
|
|
try:
|
|
|
|
subprocess.call(['espeak', '--version'])
|
|
|
|
except:
|
2016-05-20 22:15:53 +00:00
|
|
|
raise Exception(
|
2016-09-16 18:12:43 +00:00
|
|
|
'ESpeak is not installed. Run: sudo apt-get install espeak')
|
2016-05-20 14:16:01 +00:00
|
|
|
|
2016-09-16 18:12:43 +00:00
|
|
|
def get_tts_class(self):
|
2016-05-20 14:16:01 +00:00
|
|
|
return ESpeak
|