-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdo-serbian-tts.py
More file actions
executable file
·48 lines (35 loc) · 1.07 KB
/
do-serbian-tts.py
File metadata and controls
executable file
·48 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
import requests
import sys
URL = 'http://www.alfanum.co.rs/index.php/sr/demonstracija/demonstracija-tts'
def get_cookie() -> str:
response = requests.get(url=URL)
return response.headers['set-cookie'].split(';')[0]
def get_tts_link(text: str) -> str:
body = {
'input_text': text,
'outlang': 'sr',
'speaker': 'AlfaNum Danica',
'rate': 0.9995,
'pitch': 0.875,
'port': 5040,
'enc': 1,
'address': 'tts4.alfanum.co.rs',
'server_id': 0,
}
headers = {
'Referer': URL,
'Cookie': get_cookie(),
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': 'http://www.alfanum.co.rs',
'Host': 'www.alfanum.co.rs',
'Accept': 'application/json',
}
response = requests.post(
url='http://www.alfanum.co.rs/tts_req.php',
data=body,
headers=headers
)
data = response.json()
return 'https://%s:5050/ttsnovi/%s' % (body['address'], data['file'])
print(get_tts_link(' '.join(sys.argv[1:])))