-
Notifications
You must be signed in to change notification settings - Fork 0
/
infer_ts.py
69 lines (50 loc) · 1.35 KB
/
infer_ts.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import json
import argparse
import torch
import numpy as np
import soundfile as sf
from tsvitsfe import TSVITSFE
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--text",
type=str,
default=None,
help="raw text to synthesize, for single-sentence mode only",
)
parser.add_argument(
"--config",
type=str,
required=True,
help="Path to config",
)
parser.add_argument(
"--checkpoint",
type=str,
required=True,
help="Path to TorchScript-exported model file.",
)
parser.add_argument(
"--out-path",
type=str,
required=True,
help="Path to store files",
)
parser.add_argument(
"--device",
type=str,
required=True,
help="device. cuda or cpu",
)
args = parser.parse_args()
os.makedirs(
args.out_path, exist_ok=True)
vits_fe = TSVITSFE()
print("Loading model...")
vits_fe.load(args.checkpoint,args.config,args.device)
print("Doing inference...")
out_aud = vits_fe.infer(args.text)
out_fn = os.path.join(args.out_path,"audio1.wav")
sf.write(out_fn, out_aud, vits_fe.hps.data.sampling_rate)
print(f"Wrote audio file {out_fn}")