forked from OisinThomas/aac_irish
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_client.py
More file actions
48 lines (37 loc) · 1.53 KB
/
test_client.py
File metadata and controls
48 lines (37 loc) · 1.53 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
import requests
import ubelt
timer = ubelt.Timer()
#url = "http://localhost:8001"
url = "https://abair.ie/aac_irish"
voices = ["Ulster"]
caches = [True, False]
corrections = [True, False]
audioformats = ["wav","mp3"]
texts = ["dia dhuit", "dia is muire dhuit", "dia duit", "dia is muire duit"]
#texts = ["dia dhuit"]
for voice in voices:
for audioformat in audioformats:
for correction in corrections:
for cache in caches:
for text in texts:
params = {
"voice": voice,
"audioformat": audioformat,
"text": text
}
if cache:
params["use_cache"] = "on"
else:
params["use_cache"] = "off"
if correction:
params["use_correction"] = "on"
else:
params["use_correction"] = "off"
#print(params)
with timer:
data = requests.post(url,params)
outfile = f"test_out/{text}-{voice}-{cache}-{correction}.{audioformat}"
print(f"{timer.elapsed:.4f}\t{text}\t{voice}\t{audioformat}\t{cache}\t{correction}\t{outfile}", flush=True)
#print(data.elapsed)
with open(outfile, "wb") as fh:
fh.write(data.content)