Merge pull request #1 from forslund/ibm_tts_update

Ibm tts update
pull/1261/head
JarbasAI 2018-01-03 22:35:59 +00:00 committed by GitHub
commit 5eaca79bae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -16,6 +16,7 @@
from mycroft.tts import TTSValidator
from mycroft.tts.remote_tts import RemoteTTS
from mycroft.configuration import Configuration
from requests.auth import HTTPBasicAuth
class WatsonTTS(RemoteTTS):
@ -27,9 +28,9 @@ class WatsonTTS(RemoteTTS):
WatsonTTSValidator(self))
self.type = "wav"
self.config = Configuration.get().get("tts", {}).get("watson", {})
user = self.config.get("user")
user = self.config.get("user") or self.config.get("username")
password = self.config.get("password")
self.auth = (user, password)
self.auth = HTTPBasicAuth(user, password)
def build_request_params(self, sentence):
params = self.PARAMS.copy()
@ -48,8 +49,13 @@ class WatsonTTSValidator(TTSValidator):
pass
def validate_connection(self):
# TODO
pass
config = Configuration.get().get("tts", {}).get("watson", {})
user = config.get("user") or config.get("username")
password = config.get("password")
if user and password:
return
else:
raise ValueError('user and/or password for IBM tts is not defined')
def get_tts_class(self):
return WatsonTTS

View File

@ -32,6 +32,7 @@ class RemoteTTS(TTS):
def __init__(self, lang, voice, url, api_path, validator):
super(RemoteTTS, self).__init__(lang, voice, validator)
self.api_path = api_path
self.auth = None
self.url = remove_last_slash(url)
self.session = FuturesSession()
@ -64,7 +65,7 @@ class RemoteTTS(TTS):
def __request(self, p):
return self.session.get(
self.url + self.api_path, params=self.build_request_params(p),
timeout=10, verify=False)
timeout=10, verify=False, auth=self.auth)
@abc.abstractmethod
def build_request_params(self, sentence):