19 from requests.auth
import HTTPBasicAuth
23 PARAMS = {
'accept':
'audio/wav'}
26 url=
"https://stream.watsonplatform.net/text-to-speech/api"):
27 super(WatsonTTS, self).
__init__(lang, config, url,
'/v1/synthesize',
30 user = self.config.get(
"user")
or self.config.get(
"username")
31 password = self.config.get(
"password")
32 api_key = self.config.get(
"apikey")
34 self.
auth = HTTPBasicAuth(user, password)
36 self.
auth = HTTPBasicAuth(
"apikey", api_key)
39 params = self.PARAMS.copy()
40 params[
'LOCALE'] = self.
lang 41 params[
'voice'] = self.
voice 42 params[
'text'] = sentence.encode(
'utf-8')
48 super(WatsonTTSValidator, self).
__init__(tts)
55 config = Configuration.get().
get(
"tts", {}).
get(
"watson", {})
56 user = config.get(
"user")
or config.get(
"username")
57 password = config.get(
"password")
58 apikey = config.get(
"apikey")
59 if user
and password
or apikey:
62 raise ValueError(
'user/pass or apikey for IBM tts is not defined')
def validate_connection(self)
def __init__(self, lang, config, url="https://stream.watsonplatform.net/text-to-speech/api")
def get(phrase, lang=None, context=None)
def build_request_params(self, sentence)