ibm watson tts

pull/1261/head
jarbasai 2017-11-26 21:00:17 +00:00
parent 689687ef60
commit ed660183f0
2 changed files with 58 additions and 2 deletions

View File

@ -333,14 +333,15 @@ class TTSFactory(object):
from mycroft.tts.mary_tts import MaryTTS
from mycroft.tts.mimic_tts import Mimic
from mycroft.tts.spdsay_tts import SpdSay
from mycroft.tts.ibm_tts import WatsonTTS
CLASSES = {
"mimic": Mimic,
"google": GoogleTTS,
"marytts": MaryTTS,
"fatts": FATTS,
"espeak": ESpeak,
"spdsay": SpdSay
"spdsay": SpdSay,
"watson": WatsonTTS
}
@staticmethod

55
mycroft/tts/ibm_tts.py Normal file
View File

@ -0,0 +1,55 @@
# Copyright 2017 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from mycroft.tts import TTSValidator
from mycroft.tts.remote_tts import RemoteTTS
from mycroft.configuration import Configuration
class WatsonTTS(RemoteTTS):
PARAMS = {'accept': 'audio/wav'}
def __init__(self, lang, voice="en-US_AllisonVoice",
url="https://stream.watsonplatform.net/text-to-speech/api"):
super(WatsonTTS, self).__init__(lang, voice, url, '/v1/synthesize',
WatsonTTSValidator(self))
self.type = "wav"
self.config = Configuration.get().get("tts", {}).get("watson", {})
user = self.config.get("user")
password = self.config.get("password")
self.auth = (user, password)
def build_request_params(self, sentence):
params = self.PARAMS.copy()
params['LOCALE'] = self.lang
params['voice'] = self.voice
params['text'] = sentence.encode('utf-8')
return params
class WatsonTTSValidator(TTSValidator):
def __init__(self, tts):
super(WatsonTTSValidator, self).__init__(tts)
def validate_lang(self):
# TODO
pass
def validate_connection(self):
# TODO
pass
def get_tts_class(self):
return WatsonTTS