fa_tts.py
Go to the documentation of this file.
1 # Copyright 2017 Mycroft AI Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 import requests
16 
17 from mycroft.tts import TTSValidator
18 from mycroft.tts.remote_tts import RemoteTTS
19 
20 
22  PARAMS = {
23  'voice[name]': 'cmu-slt-hsmm',
24  'input[type]': 'TEXT',
25  'input[locale]': 'en_US',
26  'input[content]': 'Hello World',
27  'output[format]': 'WAVE_FILE',
28  'output[type]': 'AUDIO'
29  }
30 
31  def __init__(self, lang, config):
32  super(FATTS, self).__init__(lang, config, '/say',
33  FATTSValidator(self))
34 
35  def build_request_params(self, sentence):
36  params = self.PARAMS.copy()
37  params['voice[name]'] = self.voice
38  params['input[locale]'] = self.lang
39  params['input[content]'] = sentence.encode('utf-8')
40  return params
41 
42 
44  def __init__(self, tts):
45  super(FATTSValidator, self).__init__(tts)
46 
47  def validate_lang(self):
48  # TODO
49  pass
50 
52  try:
53  resp = requests.get(self.tts.url + "/info/version", verify=False)
54  content = resp.json()
55  if content.get('product', '').find('FA-TTS') < 0:
56  raise Exception('Invalid FA-TTS server.')
57  except Exception:
58  raise Exception(
59  'FA-TTS server could not be verified. Check your connection '
60  'to the server: ' + self.tts.url)
61 
62  def get_tts_class(self):
63  return FATTS
def build_request_params(self, sentence)
Definition: fa_tts.py:35
def __init__(self, lang, config)
Definition: fa_tts.py:31


mycroft_ros
Author(s):
autogenerated on Mon Apr 26 2021 02:35:40