commit
5eaca79bae
|
@ -16,6 +16,7 @@
|
||||||
from mycroft.tts import TTSValidator
|
from mycroft.tts import TTSValidator
|
||||||
from mycroft.tts.remote_tts import RemoteTTS
|
from mycroft.tts.remote_tts import RemoteTTS
|
||||||
from mycroft.configuration import Configuration
|
from mycroft.configuration import Configuration
|
||||||
|
from requests.auth import HTTPBasicAuth
|
||||||
|
|
||||||
|
|
||||||
class WatsonTTS(RemoteTTS):
|
class WatsonTTS(RemoteTTS):
|
||||||
|
@ -27,9 +28,9 @@ class WatsonTTS(RemoteTTS):
|
||||||
WatsonTTSValidator(self))
|
WatsonTTSValidator(self))
|
||||||
self.type = "wav"
|
self.type = "wav"
|
||||||
self.config = Configuration.get().get("tts", {}).get("watson", {})
|
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")
|
password = self.config.get("password")
|
||||||
self.auth = (user, password)
|
self.auth = HTTPBasicAuth(user, password)
|
||||||
|
|
||||||
def build_request_params(self, sentence):
|
def build_request_params(self, sentence):
|
||||||
params = self.PARAMS.copy()
|
params = self.PARAMS.copy()
|
||||||
|
@ -48,8 +49,13 @@ class WatsonTTSValidator(TTSValidator):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def validate_connection(self):
|
def validate_connection(self):
|
||||||
# TODO
|
config = Configuration.get().get("tts", {}).get("watson", {})
|
||||||
pass
|
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):
|
def get_tts_class(self):
|
||||||
return WatsonTTS
|
return WatsonTTS
|
||||||
|
|
|
@ -32,6 +32,7 @@ class RemoteTTS(TTS):
|
||||||
def __init__(self, lang, voice, url, api_path, validator):
|
def __init__(self, lang, voice, url, api_path, validator):
|
||||||
super(RemoteTTS, self).__init__(lang, voice, validator)
|
super(RemoteTTS, self).__init__(lang, voice, validator)
|
||||||
self.api_path = api_path
|
self.api_path = api_path
|
||||||
|
self.auth = None
|
||||||
self.url = remove_last_slash(url)
|
self.url = remove_last_slash(url)
|
||||||
self.session = FuturesSession()
|
self.session = FuturesSession()
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ class RemoteTTS(TTS):
|
||||||
def __request(self, p):
|
def __request(self, p):
|
||||||
return self.session.get(
|
return self.session.get(
|
||||||
self.url + self.api_path, params=self.build_request_params(p),
|
self.url + self.api_path, params=self.build_request_params(p),
|
||||||
timeout=10, verify=False)
|
timeout=10, verify=False, auth=self.auth)
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def build_request_params(self, sentence):
|
def build_request_params(self, sentence):
|
||||||
|
|
Loading…
Reference in New Issue