Skip to content

Commit ad40746

Browse files
committed
Add proxy support
1 parent 3209cfc commit ad40746

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tts.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,38 @@
66

77
temp = './temp/'
88

9+
print('Google TTS version 1.0 by ReekyStive')
10+
print('Type ":quit" to quit, type ":proxy" to set proxy.')
11+
print('Type anything to start.')
912

1013
while (True):
1114
s = input('> ')
15+
if s.strip() == ':quit':
16+
break
17+
elif s.strip() == ':proxy':
18+
server = input('HTTP Proxy server: ')
19+
os.environ['http_proxy'] = server
20+
os.environ['https_proxy'] = server
21+
print('Proxy is set.\n')
22+
continue
1223

1324
print('Generating...', end='')
1425
sys.stdout.flush()
1526
try:
1627
os.remove(temp + 'speech.mp3')
1728
except:
1829
pass
19-
tts = gtts(s)
20-
tts.save(temp + 'speech.mp3')
30+
try:
31+
tts = gtts(s)
32+
tts.save(temp + 'speech.mp3')
33+
except AssertionError:
34+
print(' Nothing to generate.\n')
35+
continue
36+
except:
37+
print(' Failed.')
38+
print('Please check your connection with Google.')
39+
print('Enter ":proxy" to set proxy.\n')
40+
continue
2141

2242
print(' Decoding...', end='')
2343
sys.stdout.flush()

0 commit comments

Comments
 (0)