-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_generate.py
More file actions
32 lines (21 loc) · 843 Bytes
/
Copy pathtest_generate.py
File metadata and controls
32 lines (21 loc) · 843 Bytes
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
import json
import sys
from pathlib import Path
from src.generate import generate
from src.models import TtsRequest
def main():
input_path = Path(sys.argv[1]) if len(sys.argv) > 1 else Path("test/test_requests.json")
output_dir = Path(sys.argv[2]) if len(sys.argv) > 2 else Path("test/output")
output_dir.mkdir(parents=True, exist_ok=True)
with open(input_path) as f:
requests = json.load(f)
for i, raw in enumerate(requests):
request = TtsRequest(**raw)
print(f" [{i + 1}/{len(requests)}] {request.id} — \"{request.t[:40]}...\" voice={request.r}")
ogg = generate(request)
out_path = output_dir / f"{request.id}.ogg"
out_path.write_bytes(ogg)
print(f" -> {out_path} ({len(ogg)} bytes)")
print("Done.")
if __name__ == "__main__":
main()