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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"name": "四国めたん",
|
4 |
+
"styles": [
|
5 |
+
{"name": "ノーマル", "id": 2},
|
6 |
+
{"name": "あまあま", "id": 0},
|
7 |
+
{"name": "ツンツン", "id": 6},
|
8 |
+
{"name": "セクシー", "id": 4},
|
9 |
+
{"name": "ささやき", "id": 36},
|
10 |
+
{"name": "ヒソヒソ", "id": 37}
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"name": "ずんだもん",
|
15 |
+
"styles": [
|
16 |
+
{"name": "ノーマル", "id": 3},
|
17 |
+
{"name": "あまあま", "id": 1},
|
18 |
+
{"name": "ツンツン", "id": 7},
|
19 |
+
{"name": "セクシー", "id": 5},
|
20 |
+
{"name": "ささやき", "id": 22},
|
21 |
+
{"name": "ヒソヒソ", "id": 38},
|
22 |
+
{"name": "ヘロヘロ", "id": 75},
|
23 |
+
{"name": "なみだめ", "id": 76}
|
24 |
+
]
|
25 |
+
},
|
26 |
+
{
|
27 |
+
"name": "春日部つむぎ",
|
28 |
+
"styles": [
|
29 |
+
{"name": "ノーマル", "id": 8}
|
30 |
+
]
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"name": "雨晴はう",
|
34 |
+
"styles": [
|
35 |
+
{"name": "ノーマル", "id": 10}
|
36 |
+
]
|
37 |
+
},
|
38 |
+
{
|
39 |
+
"name": "波音リツ",
|
40 |
+
"styles": [
|
41 |
+
{"name": "ノーマル", "id": 9},
|
42 |
+
{"name": "クイーン", "id": 65}
|
43 |
+
]
|
44 |
+
},
|
45 |
+
{
|
46 |
+
"name": "玄野武宏",
|
47 |
+
"styles": [
|
48 |
+
{"name": "ノーマル", "id": 11},
|
49 |
+
{"name": "喜び", "id": 39},
|
50 |
+
{"name": "ツンギレ", "id": 40},
|
51 |
+
{"name": "悲しみ", "id": 41}
|
52 |
+
]
|
53 |
+
},
|
54 |
+
{
|
55 |
+
"name": "白上虎太郎",
|
56 |
+
"styles": [
|
57 |
+
{"name": "ふつう", "id": 12},
|
58 |
+
{"name": "わーい", "id": 32},
|
59 |
+
{"name": "びくびく", "id": 33},
|
60 |
+
{"name": "おこ", "id": 34},
|
61 |
+
{"name": "びえーん", "id": 35}
|
62 |
+
]
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"name": "青山龍星",
|
66 |
+
"styles": [
|
67 |
+
{"name": "ノーマル", "id": 13},
|
68 |
+
{"name": "熱血", "id": 81},
|
69 |
+
{"name": "不機嫌", "id": 82},
|
70 |
+
{"name": "喜び", "id": 83},
|
71 |
+
{"name": "しっとり", "id": 84},
|
72 |
+
{"name": "かなしみ", "id": 85},
|
73 |
+
{"name": "囁き", "id": 86}
|
74 |
+
]
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"name": "冥鳴ひまり",
|
78 |
+
"styles": [
|
79 |
+
{"name": "ノーマル", "id": 14}
|
80 |
+
]
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"name": "九州そら",
|
84 |
+
"styles": [
|
85 |
+
{"name": "ノーマル", "id": 16},
|
86 |
+
{"name": "あまあま", "id": 15},
|
87 |
+
{"name": "ツンツン", "id": 18},
|
88 |
+
{"name": "セクシー", "id": 17},
|
89 |
+
{"name": "ささやき", "id": 19}
|
90 |
+
]
|
91 |
+
},
|
92 |
+
{
|
93 |
+
"name": "もち子さん",
|
94 |
+
"styles": [
|
95 |
+
{"name": "ノーマル", "id": 20},
|
96 |
+
{"name": "セクシー/あん子", "id": 66},
|
97 |
+
{"name": "泣き", "id": 77},
|
98 |
+
{"name": "怒り", "id": 78},
|
99 |
+
{"name": "喜び", "id": 79},
|
100 |
+
{"name": "のんびり", "id": 80}
|
101 |
+
]
|
102 |
+
},
|
103 |
+
{
|
104 |
+
"name": "剣崎雌雄",
|
105 |
+
"styles": [
|
106 |
+
{"name": "ノーマル", "id": 21}
|
107 |
+
]
|
108 |
+
},
|
109 |
+
{
|
110 |
+
"name": "WhiteCUL",
|
111 |
+
"styles": [
|
112 |
+
{"name": "ノーマル", "id": 23},
|
113 |
+
{"name": "たのしい", "id": 24},
|
114 |
+
{"name": "かなしい", "id": 25},
|
115 |
+
{"name": "びえーん", "id": 26}
|
116 |
+
]
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"name": "後鬼",
|
120 |
+
"styles": [
|
121 |
+
{"name": "人間ver.", "id": 27},
|
122 |
+
{"name": "ぬいぐるみver.", "id": 28}
|
123 |
+
]
|
124 |
+
},
|
125 |
+
{
|
126 |
+
"name": "No.7",
|
127 |
+
"styles": [
|
128 |
+
{"name": "ノーマル", "id": 29},
|
129 |
+
{"name": "アナウンス", "id": 30},
|
130 |
+
{"name": "読み聞かせ", "id": 31}
|
131 |
+
]
|
132 |
+
},
|
133 |
+
{
|
134 |
+
"name": "ちび式じい",
|
135 |
+
"styles": [
|
136 |
+
{"name": "ノーマル", "id": 42}
|
137 |
+
]
|
138 |
+
},
|
139 |
+
{
|
140 |
+
"name": "櫻歌ミコ",
|
141 |
+
"styles": [
|
142 |
+
{"name": "ノーマル", "id": 43},
|
143 |
+
{"name": "第二形態", "id": 44},
|
144 |
+
{"name": "ロリ", "id": 45}
|
145 |
+
]
|
146 |
+
},
|
147 |
+
{
|
148 |
+
"name": "小夜/SAYO",
|
149 |
+
"styles": [
|
150 |
+
{"name": "ノーマル", "id": 46}
|
151 |
+
]
|
152 |
+
},
|
153 |
+
{
|
154 |
+
"name": "ナースロボ_タイプT",
|
155 |
+
"styles": [
|
156 |
+
{"name": "ノーマル", "id": 47},
|
157 |
+
{"name": "楽々", "id": 48},
|
158 |
+
{"name": "恐怖", "id": 49},
|
159 |
+
{"name": "内緒話", "id": 50}
|
160 |
+
]
|
161 |
+
},
|
162 |
+
{
|
163 |
+
"name": "†聖騎士 紅桜†",
|
164 |
+
"styles": [
|
165 |
+
{"name": "ノーマル", "id": 51}
|
166 |
+
]
|
167 |
+
},
|
168 |
+
{
|
169 |
+
"name": "雀松朱司",
|
170 |
+
"styles": [
|
171 |
+
{"name": "ノーマル", "id": 52}
|
172 |
+
]
|
173 |
+
},
|
174 |
+
{
|
175 |
+
"name": "麒ヶ島宗麟",
|
176 |
+
"styles": [
|
177 |
+
{"name": "ノーマル", "id": 53}
|
178 |
+
]
|
179 |
+
},
|
180 |
+
{
|
181 |
+
"name": "春歌ナナ",
|
182 |
+
"styles": [
|
183 |
+
{"name": "ノーマル", "id": 54}
|
184 |
+
]
|
185 |
+
},
|
186 |
+
{
|
187 |
+
"name": "猫使アル",
|
188 |
+
"styles": [
|
189 |
+
{"name": "ノーマル", "id": 55},
|
190 |
+
{"name": "おちつき", "id": 56},
|
191 |
+
{"name": "うきうき", "id": 57}
|
192 |
+
]
|
193 |
+
},
|
194 |
+
{
|
195 |
+
"name": "猫使ビィ",
|
196 |
+
"styles": [
|
197 |
+
{"name": "ノーマル", "id": 58},
|
198 |
+
{"name": "おちつき", "id": 59},
|
199 |
+
{"name": "人見知り", "id": 60}
|
200 |
+
]
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"name": "中国うさぎ",
|
204 |
+
"styles": [
|
205 |
+
{"name": "ノーマル", "id": 61},
|
206 |
+
{"name": "おどろき", "id": 62},
|
207 |
+
{"name": "こわがり", "id": 63},
|
208 |
+
{"name": "へろへろ", "id": 64}
|
209 |
+
]
|
210 |
+
},
|
211 |
+
{
|
212 |
+
"name": "栗田まろん",
|
213 |
+
"styles": [
|
214 |
+
{"name": "ノーマル", "id": 67}
|
215 |
+
]
|
216 |
+
},
|
217 |
+
{
|
218 |
+
"name": "あいえるたん",
|
219 |
+
"styles": [
|
220 |
+
{"name": "ノーマル", "id": 68}
|
221 |
+
]
|
222 |
+
},
|
223 |
+
{
|
224 |
+
"name": "満別花丸",
|
225 |
+
"styles": [
|
226 |
+
{"name": "ノーマル", "id": 69},
|
227 |
+
{"name": "元気", "id": 70},
|
228 |
+
{"name": "ささやき", "id": 71},
|
229 |
+
{"name": "ぶりっ子", "id": 72},
|
230 |
+
{"name": "ボーイ", "id": 73}
|
231 |
+
]
|
232 |
+
},
|
233 |
+
{
|
234 |
+
"name": "琴詠ニア",
|
235 |
+
"styles": [
|
236 |
+
{"name": "ノーマル", "id": 74}
|
237 |
+
]
|
238 |
+
}
|
239 |
+
]
|
240 |
+
|
ROHAN-corpus/create-ROHAN-corpus-voice.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import requests
|
3 |
+
import json
|
4 |
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
5 |
+
import argparse
|
6 |
+
|
7 |
+
def synthesize_and_save(batch, voicevox_engine_url):
|
8 |
+
for task in batch:
|
9 |
+
file_name, text, char_name, style_name, style_id = task
|
10 |
+
try:
|
11 |
+
# フォルダを作成する
|
12 |
+
output_folder = f"{char_name}_{style_name}"
|
13 |
+
os.makedirs(output_folder, exist_ok=True)
|
14 |
+
|
15 |
+
# 出力ファイル名を作成する
|
16 |
+
output_file_name = os.path.join(output_folder, f"{file_name}.wav")
|
17 |
+
|
18 |
+
# 既にファイルが存在する場合はスキップ
|
19 |
+
if os.path.exists(output_file_name):
|
20 |
+
print(f"File {output_file_name} already exists, skipping.")
|
21 |
+
continue
|
22 |
+
|
23 |
+
# 音声合成クエリを作成する
|
24 |
+
query_response = requests.post(
|
25 |
+
f"{voicevox_engine_url}/audio_query",
|
26 |
+
params={"text": text, "speaker": style_id},
|
27 |
+
headers={"Content-Type": "application/json"}
|
28 |
+
)
|
29 |
+
|
30 |
+
if query_response.status_code != 200:
|
31 |
+
print(f"Failed to create audio query for {file_name} with character {char_name} and style {style_name}")
|
32 |
+
continue
|
33 |
+
|
34 |
+
query = query_response.json()
|
35 |
+
|
36 |
+
# 音声合成を実行する
|
37 |
+
synthesis_response = requests.post(
|
38 |
+
f"{voicevox_engine_url}/synthesis",
|
39 |
+
params={"speaker": style_id},
|
40 |
+
data=json.dumps(query),
|
41 |
+
headers={"Content-Type": "application/json"}
|
42 |
+
)
|
43 |
+
|
44 |
+
if synthesis_response.status_code != 200:
|
45 |
+
print(f"Failed to synthesize audio for {file_name} with character {char_name} and style {style_name}")
|
46 |
+
continue
|
47 |
+
|
48 |
+
# 音声ファイルを保存する
|
49 |
+
with open(output_file_name, "wb") as out_f:
|
50 |
+
out_f.write(synthesis_response.content)
|
51 |
+
|
52 |
+
print(f"Saved {output_file_name}")
|
53 |
+
except Exception as e:
|
54 |
+
print(f"Exception occurred for {file_name} with character {char_name} and style {style_name}: {e}")
|
55 |
+
|
56 |
+
def main(max_workers, batch_size):
|
57 |
+
# VOICEVOXエンジンのURL
|
58 |
+
VOICEVOX_ENGINE_URL = "http://localhost:50021"
|
59 |
+
|
60 |
+
# キャラクター情報をJSONファイルからロードする
|
61 |
+
with open("character_config.json", "r", encoding="utf-8") as f:
|
62 |
+
CHARACTERS = json.load(f)
|
63 |
+
|
64 |
+
# テキストファイルを読み込む
|
65 |
+
with open("Rohan4600_transcript_utf8.txt", "r", encoding="utf-8") as f:
|
66 |
+
lines = f.readlines()
|
67 |
+
|
68 |
+
tasks = []
|
69 |
+
for line in lines:
|
70 |
+
parts = line.strip().split(":")
|
71 |
+
file_name = parts[0].strip()
|
72 |
+
text_parts = parts[1].split(",")
|
73 |
+
text = text_parts[0].strip() # 2列目(使用するテキスト)
|
74 |
+
|
75 |
+
for character in CHARACTERS:
|
76 |
+
char_name = character["name"]
|
77 |
+
for style in character["styles"]:
|
78 |
+
style_name = style["name"]
|
79 |
+
style_id = style["id"]
|
80 |
+
tasks.append((file_name, text, char_name, style_name, style_id))
|
81 |
+
|
82 |
+
# タスクをバッチに分ける
|
83 |
+
batches = [tasks[i:i + batch_size] for i in range(0, len(tasks), batch_size)]
|
84 |
+
|
85 |
+
# 並列処理の実行
|
86 |
+
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
87 |
+
futures = [executor.submit(synthesize_and_save, batch, VOICEVOX_ENGINE_URL) for batch in batches]
|
88 |
+
|
89 |
+
for future in as_completed(futures):
|
90 |
+
future.result() # 各タスクの結果を取得する(例外が発生した場合に備えて)
|
91 |
+
|
92 |
+
print("All tasks completed.")
|
93 |
+
|
94 |
+
if __name__ == "__main__":
|
95 |
+
parser = argparse.ArgumentParser(description="Parallel voice synthesis script")
|
96 |
+
parser.add_argument("--max_workers", type=int, default=128, help="Number of parallel workers")
|
97 |
+
parser.add_argument("--batch_size", type=int, default=10, help="Number of tasks per batch")
|
98 |
+
args = parser.parse_args()
|
99 |
+
main(args.max_workers, args.batch_size)
|
ROHAN-corpus/upload_dataset.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import concurrent.futures
|
3 |
+
from huggingface_hub import HfApi
|
4 |
+
from tqdm import tqdm
|
5 |
+
|
6 |
+
# Huggingfaceの認証トークン
|
7 |
+
hf_token = "token"
|
8 |
+
hf_repo_id = "ayousanz/voicevox-voice-corpus"
|
9 |
+
hf_repo_type = "dataset" # データセットとしてアップロード
|
10 |
+
|
11 |
+
# フォルダのパス
|
12 |
+
base_dir = r"C:\Users\yuta\Desktop\Private\voicevox-voice-corpus\ROHAN-corpus"
|
13 |
+
|
14 |
+
# HfApiインスタンスの作成
|
15 |
+
api = HfApi()
|
16 |
+
|
17 |
+
def upload_subfolder(subfolder):
|
18 |
+
try:
|
19 |
+
# パスの区切り文字をスラッシュに統一
|
20 |
+
relative_path = os.path.relpath(subfolder, base_dir).replace(os.sep, '/')
|
21 |
+
api.upload_folder(
|
22 |
+
folder_path=subfolder,
|
23 |
+
path_in_repo=f"ROHAN-corpus/{relative_path}",
|
24 |
+
repo_id=hf_repo_id,
|
25 |
+
repo_type=hf_repo_type,
|
26 |
+
token=hf_token
|
27 |
+
)
|
28 |
+
print(f"\nUploaded contents of {subfolder}")
|
29 |
+
except Exception as e:
|
30 |
+
print(f"\nFailed to upload {subfolder}: {e}")
|
31 |
+
|
32 |
+
# フォルダ内のサブフォルダを取得
|
33 |
+
subfolders = [f.path for f in os.scandir(base_dir) if f.is_dir()]
|
34 |
+
|
35 |
+
# プログレスバーを使用して非同期にアップロード
|
36 |
+
with tqdm(total=len(subfolders), desc="Uploading folders", unit="folder") as pbar:
|
37 |
+
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
|
38 |
+
futures = {executor.submit(upload_subfolder, subfolder): subfolder for subfolder in subfolders}
|
39 |
+
for future in concurrent.futures.as_completed(futures):
|
40 |
+
subfolder = futures[future]
|
41 |
+
try:
|
42 |
+
future.result()
|
43 |
+
pbar.update(1)
|
44 |
+
except Exception as e:
|
45 |
+
print(f"\nError uploading {subfolder}: {e}")
|
46 |
+
|
47 |
+
print("All files uploaded.")
|