diff --git a/mycroft/tts/ibm_tts.py b/mycroft/tts/ibm_tts.py index 7263b5f962..d07e23ba97 100644 --- a/mycroft/tts/ibm_tts.py +++ b/mycroft/tts/ibm_tts.py @@ -23,13 +23,17 @@ class WatsonTTS(RemoteTTS): PARAMS = {'accept': 'audio/wav'} def __init__(self, lang, config, - url="https://stream.watsonplatform.net/text-to-speech/api"): - super(WatsonTTS, self).__init__(lang, config, url, '/v1/synthesize', + url='https://stream.watsonplatform.net/text-to-speech/api', + api_path='/v1/synthesize'): + super(WatsonTTS, self).__init__(lang, config, url, api_path, WatsonTTSValidator(self)) self.type = "wav" user = self.config.get("user") or self.config.get("username") password = self.config.get("password") api_key = self.config.get("apikey") + if self.url.endswith(api_path): + self.url = self.url[:-len(api_path)] + if api_key is None: self.auth = HTTPBasicAuth(user, password) else: @@ -39,6 +43,8 @@ class WatsonTTS(RemoteTTS): params = self.PARAMS.copy() params['LOCALE'] = self.lang params['voice'] = self.voice + params['X-Watson-Learning-Opt-Out'] = self.config.get( + 'X-Watson-Learning-Opt-Out', 'true') params['text'] = sentence.encode('utf-8') return params diff --git a/mycroft/tts/remote_tts.py b/mycroft/tts/remote_tts.py index 0c64520e82..8c70eba48a 100644 --- a/mycroft/tts/remote_tts.py +++ b/mycroft/tts/remote_tts.py @@ -17,7 +17,7 @@ import re from requests_futures.sessions import FuturesSession from .tts import TTS -from mycroft.util import remove_last_slash, play_wav +from mycroft.util import play_wav from mycroft.util.log import LOG @@ -41,7 +41,7 @@ class RemoteTTS(TTS): super(RemoteTTS, self).__init__(lang, config, validator) self.api_path = api_path self.auth = None - self.url = remove_last_slash(url) + self.url = config.get('url', url).rstrip('/') self.session = FuturesSession() def execute(self, sentence, ident=None, listen=False):