google_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 from gtts import gTTS
16 
17 from mycroft.tts import TTS, TTSValidator
18 
19 
20 class GoogleTTS(TTS):
21  def __init__(self, lang, config):
22  super(GoogleTTS, self).__init__(lang, config, GoogleTTSValidator(
23  self), 'mp3')
24 
25  def get_tts(self, sentence, wav_file):
26  tts = gTTS(sentence, self.lang)
27  tts.save(wav_file)
28  return (wav_file, None) # No phonemes
29 
30 
32  def __init__(self, tts):
33  super(GoogleTTSValidator, self).__init__(tts)
34 
35  def validate_lang(self):
36  # TODO
37  pass
38 
40  try:
41  gTTS(text='Hi').save(self.tts.filename)
42  except Except:
43  raise Exception(
44  'GoogleTTS server could not be verified. Please check your '
45  'internet connection.')
46 
47  def get_tts_class(self):
48  return GoogleTTS
def get_tts(self, sentence, wav_file)
Definition: google_tts.py:25
def __init__(self, lang, config)
Definition: google_tts.py:21


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