akikukeo
add 10k~20k models
36e7c0d
import os
import yaml
# このスクリプトは PyYAML ライブラリが必要です。
# pip install PyYAML
def convert_yaml_to_esd_list():
"""
esd.yaml を読み込み、esd.list 形式に変換して出力します。
"""
try:
# スクリプトの場所を基準にパスを設定
base_dir = os.path.dirname(os.path.abspath(__file__))
input_yaml_path = os.path.join(base_dir, "Inputs", "esd.yaml")
output_dir = os.path.join(base_dir, "Outputs")
output_list_path = os.path.join(output_dir, "esd.list")
# 出力フォルダが存在しない場合は作成
os.makedirs(output_dir, exist_ok=True)
# esd.yaml の読み込み
print(f"'{input_yaml_path}' を読み込んでいます...")
with open(input_yaml_path, 'r', encoding='utf-8') as f:
data = yaml.safe_load(f)
print("読み込みが完了しました。")
output_lines = []
speaker = "Tsukuyomi-chan"
language = "JP"
# データの処理
print("データを esd.list 形式に変換しています...")
for key, value in data.items():
if isinstance(value, dict) and 'text_level2' in value:
filename = f"{key}.wav"
text = value['text_level2']
# フォーマット: "ファイル名|話者|言語|テキスト"
line = f"{filename}|{speaker}|{language}|{text}"
output_lines.append(line)
# esd.list ファイルへの書き込み
print(f"'{output_list_path}' に書き込んでいます...")
with open(output_list_path, 'w', encoding='utf-8') as f:
f.write('\n'.join(output_lines))
print("変換が正常に完了しました。")
print(f"出力ファイル: {output_list_path}")
except FileNotFoundError:
print(f"エラー: 入力ファイルが見つかりません。パスを確認してください: {input_yaml_path}")
except Exception as e:
print(f"エラーが発生しました: {e}")
if __name__ == "__main__":
convert_yaml_to_esd_list()