Skip to content

Commit

Permalink
Merge pull request #1983 from LuisReinoso/feature/issue-1982
Browse files Browse the repository at this point in the history
Issues-1982 - Add IAM authentication for Watson TTS
  • Loading branch information
forslund committed Feb 27, 2019
2 parents df7dfaa + 62f0abf commit 0714127
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mycroft/tts/ibm_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def __init__(self, lang, config,
self.type = "wav"
user = self.config.get("user") or self.config.get("username")
password = self.config.get("password")
self.auth = HTTPBasicAuth(user, password)
api_key = self.config.get("apikey")
if api_key is None:
self.auth = HTTPBasicAuth(user, password)
else:
self.auth = HTTPBasicAuth("apikey", api_key)

def build_request_params(self, sentence):
params = self.PARAMS.copy()
Expand All @@ -51,10 +55,11 @@ def validate_connection(self):
config = Configuration.get().get("tts", {}).get("watson", {})
user = config.get("user") or config.get("username")
password = config.get("password")
if user and password:
apikey = config.get("apikey")
if user and password or apikey:
return
else:
raise ValueError('user and/or password for IBM tts is not defined')
raise ValueError('user/pass or apikey for IBM tts is not defined')

def get_tts_class(self):
return WatsonTTS

0 comments on commit 0714127

Please sign in to comment.