forked from VOICEVOX/voicevox_core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
46 lines (37 loc) · 1.21 KB
/
run.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
import argparse
from typing import Optional
import core
import soundfile
from forwarder import Forwarder
def run(
use_gpu: bool,
text: str,
speaker_id: int,
f0_speaker_id: Optional[int],
f0_correct: float,
) -> None:
# コアの初期化
core.initialize("./", use_gpu)
# 音声合成処理モジュールの初期化
forwarder = Forwarder(
yukarin_s_forwarder=core.yukarin_s_forward,
yukarin_sa_forwarder=core.yukarin_sa_forward,
decode_forwarder=core.decode_forward,
)
# 音声合成
wave = forwarder.forward(
text=text,
speaker_id=speaker_id,
f0_speaker_id=f0_speaker_id if f0_speaker_id is not None else speaker_id,
f0_correct=f0_correct,
)
# 保存
soundfile.write(f"{text}-{speaker_id}.wav", data=wave, samplerate=24000)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--use_gpu", action="store_true")
parser.add_argument("--text", required=True)
parser.add_argument("--speaker_id", type=int, required=True)
parser.add_argument("--f0_speaker_id", type=int)
parser.add_argument("--f0_correct", type=float, default=0)
run(**vars(parser.parse_args()))