Skip to content

Commit dfebede

Browse files
committed
Fixed Google TTS as of 2021-01-29
The gTTS code does still work, but Google seems to have abandoned the 'zh-CN', 'zh-cn', 'zh-tw' language codes in favor of just 'zh'. This commit changes all 'zh-CN/cn' occurrences to 'zh' and removes the rest if possible.
1 parent 2ae3be4 commit dfebede

File tree

5 files changed

+6
-9
lines changed

5 files changed

+6
-9
lines changed

chinese/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"firstRun": true,
33
"version": "0.13.0",
44
"enabledModels": [],
5-
"speech": "google|zh-cn",
5+
"speech": "google|zh",
66
"target": "pinyin",
77
"fields": {
88
"hanzi": [

chinese/gui.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
SPEECH_ENGINES = {
4141
'Baidu Translate': 'baidu|zh',
42-
'Google Mandarin (PRC)': 'google|zh-cn',
43-
'Google Mandarin (Taiwan)': 'google|zh-tw',
42+
'Google Mandarin (PRC)': 'google|zh',
43+
# 'Google Mandarin (Taiwan)': 'google|zh-tw', # Does not work as of 2021-01-29
4444
'Amazon Polly' : 'aws|Zhiyu',
4545
'Disabled': None,
4646
}

chinese/lib/gtts/lang.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def _main_langs():
9898
'uk': 'Ukrainian',
9999
'ur': 'Urdu',
100100
'vi': 'Vietnamese',
101-
'zh-CN': 'Chinese'
101+
'zh': 'Chinese'
102102
}
103103

104104

@@ -114,9 +114,6 @@ def _extra_langs():
114114
115115
"""
116116
return {
117-
# Chinese
118-
'zh-cn': 'Chinese (Mandarin/China)',
119-
'zh-tw': 'Chinese (Mandarin/Taiwan)',
120117
# English
121118
'en-us': 'English (US)',
122119
'en-ca': 'English (Canada)',

chinese/tts.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
class AudioDownloader:
24-
def __init__(self, text, source='google|zh-cn'):
24+
def __init__(self, text, source='google|zh'):
2525
self.text = text
2626
self.service, self.lang = source.split('|')
2727
self.path = self.get_path()

tests/test_behavior.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def model(self):
299299
'Ruby (Bopomofo)': '<span class="tone2"><ruby>床<rt>ㄔㄨㄤˊ</rt></ruby></span><span class="tone1"><ruby>单<rt>ㄉㄢ</rt></ruby></span>',
300300
'Ruby (Jyutping)': '',
301301
'Silhouette': '_ _',
302-
'Sound (Mandarin)': '[sound:床单_google_zh-cn.mp3]',
302+
'Sound (Mandarin)': '[sound:床单_google_zh.mp3]',
303303
'Sound (Cantonese)': '',
304304
}
305305
fields = expected.keys()

0 commit comments

Comments
 (0)