Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2831 from MycroftAI/bugfix/google-voice
Browse files Browse the repository at this point in the history
Upgrade gTTS to fix Google voice
krisgesling authored Feb 10, 2021
2 parents 36b2c41 + c849493 commit fa5576a
Showing 3 changed files with 8 additions and 21 deletions.
17 changes: 2 additions & 15 deletions mycroft/tts/google_tts.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
from mycroft.util.log import LOG

# Live list of languages
# Cached list of supported languages (2020-05-27)
# Cached list of supported languages (2021-02-09)
_default_langs = {'af': 'Afrikaans', 'sq': 'Albanian', 'ar': 'Arabic',
'hy': 'Armenian', 'bn': 'Bengali', 'bs': 'Bosnian',
'ca': 'Catalan', 'hr': 'Croatian', 'cs': 'Czech',
@@ -40,20 +40,7 @@
'su': 'Sundanese', 'sw': 'Swahili', 'sv': 'Swedish',
'ta': 'Tamil', 'te': 'Telugu', 'th': 'Thai', 'tr': 'Turkish',
'uk': 'Ukrainian', 'ur': 'Urdu', 'vi': 'Vietnamese',
'cy': 'Welsh', 'zh-cn': 'Chinese (Mandarin/China)',
'zh-tw': 'Chinese (Mandarin/Taiwan)',
'en-us': 'English (US)', 'en-ca': 'English (Canada)',
'en-uk': 'English (UK)', 'en-gb': 'English (UK)',
'en-au': 'English (Australia)', 'en-gh': 'English (Ghana)',
'en-in': 'English (India)', 'en-ie': 'English (Ireland)',
'en-nz': 'English (New Zealand)',
'en-ng': 'English (Nigeria)',
'en-ph': 'English (Philippines)',
'en-za': 'English (South Africa)',
'en-tz': 'English (Tanzania)', 'fr-ca': 'French (Canada)',
'fr-fr': 'French (France)', 'pt-br': 'Portuguese (Brazil)',
'pt-pt': 'Portuguese (Portugal)', 'es-es': 'Spanish (Spain)',
'es-us': 'Spanish (United States)'
'cy': 'Welsh', 'zh': 'Chinese (Mandarin/China)'
}


2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
requests==2.20.0
gTTS==2.2.0
gTTS>=2.2.2,<2.3.0
PyAudio==0.2.11
pyee==8.1.0
SpeechRecognition==3.8.1
10 changes: 5 additions & 5 deletions test/unittests/tts/test_google_tts.py
Original file line number Diff line number Diff line change
@@ -11,14 +11,14 @@ class TestGoogleTTS(unittest.TestCase):
def test_get_tts(self, _, gtts_mock):
gtts_response = mock.Mock()
gtts_mock.return_value = gtts_response
tts = GoogleTTS('en-US', {})
tts = GoogleTTS('en', {})
sentence = 'help me Obi-Wan Kenobi, you are my only hope'
mp3_file, vis = tts.get_tts(sentence, 'output.mp3')
gtts_mock.assert_called_with(text=sentence, lang='en-us')
gtts_mock.assert_called_with(text=sentence, lang='en')
gtts_response.save.assert_called_with('output.mp3')

def test_validator(self, _, gtts_mock):
validator = GoogleTTSValidator(GoogleTTS('en-US', {}))
validator = GoogleTTSValidator(GoogleTTS('en', {}))
validator.validate_connection()
with self.assertRaises(Exception):
def sideeffect(**kwargs):
@@ -33,5 +33,5 @@ def test_lang_connection_error(self, mock_get_langs, _, gtts_mock):
def sideeffect(**kwargs):
raise Exception
mock_get_langs.side_effect = sideeffect
tts = GoogleTTS('en-US', {})
self.assertEqual(tts.google_lang, 'en-us')
tts = GoogleTTS('en', {})
self.assertEqual(tts.google_lang, 'en')

0 comments on commit fa5576a

Please sign in to comment.