Skip to content

Commit 94d0eb7

Browse files
committed
Catch gTTS errors and log to console
1 parent daa0886 commit 94d0eb7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

chinese/tts.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright © 2012 Thomas TEMPÉ <[email protected]>
33
# Copyright © 2017 Pu Anlai <https://github.com/InspectorMustache>
44
# Copyright © 2019 Oliver Rice <[email protected]>
5-
# Copyright © 2017-2019 Joseph Lorimer <[email protected]>
5+
# Copyright © 2017-2021 Joseph Lorimer <[email protected]>
66
# Inspiration: Tymon Warecki
77
# License: GNU AGPL, version 3 or later; http://www.gnu.org/copyleft/agpl.html
88

@@ -16,6 +16,7 @@
1616
import requests
1717
from aqt import mw
1818
from gtts import gTTS
19+
from gtts.tts import gTTSError
1920

2021
requests.packages.urllib3.disable_warnings()
2122

@@ -53,7 +54,10 @@ def download(self):
5354

5455
def get_google(self):
5556
tts = gTTS(self.text, lang=self.lang)
56-
tts.save(self.path)
57+
try:
58+
tts.save(self.path)
59+
except gTTSError as e:
60+
print('gTTS Error: {}'.format(e))
5761

5862
def get_baidu(self):
5963
query = {

0 commit comments

Comments
 (0)