43 lines
982 B
Python
43 lines
982 B
Python
#!/usr/bin/env python3
|
|
"""生成 assets/tts_cache/wake_greeting.wav。须与 voice_drone.main_app._WAKE_GREETING 一致。
|
|
|
|
用法(在 voice_drone_assistant 根目录):
|
|
python scripts/generate_wake_greeting_wav.py
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
_ROOT = Path(__file__).resolve().parents[1]
|
|
if str(_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(_ROOT))
|
|
try:
|
|
os.chdir(_ROOT)
|
|
except OSError:
|
|
pass
|
|
|
|
from voice_drone.core.portaudio_env import fix_ld_path_for_portaudio
|
|
|
|
fix_ld_path_for_portaudio()
|
|
|
|
_WAKE_TEXT = "你好,我在呢"
|
|
|
|
|
|
def main() -> None:
|
|
out_dir = _ROOT / "assets" / "tts_cache"
|
|
out_dir.mkdir(parents=True, exist_ok=True)
|
|
out_path = out_dir / "wake_greeting.wav"
|
|
|
|
from voice_drone.core.tts import KokoroOnnxTTS
|
|
|
|
tts = KokoroOnnxTTS()
|
|
tts.synthesize_to_file(_WAKE_TEXT, str(out_path))
|
|
print(f"已写入: {out_path}", flush=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|