Initial commit: Korean voice-cloning TTS prototype
FastAPI backend, web UI, CosyVoice3/F5-TTS setup scripts, and handoff docs for GPU PC continuation. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
47
scripts/workers/f5_infer.py
Normal file
47
scripts/workers/f5_infer.py
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python3
|
||||
"""F5-TTS 추론 워커 (f5tts venv에서 실행)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="F5-TTS inference worker")
|
||||
parser.add_argument("--ref-audio", required=True, help="Reference WAV path")
|
||||
parser.add_argument("--ref-text", required=True, help="Transcript of reference audio")
|
||||
parser.add_argument("--gen-text", required=True, help="Text to synthesize")
|
||||
parser.add_argument("--out", required=True, help="Output WAV path")
|
||||
parser.add_argument("--model", default="F5TTS_v1_Base")
|
||||
args = parser.parse_args()
|
||||
|
||||
ref = Path(args.ref_audio)
|
||||
if not ref.is_file():
|
||||
print(f"ref audio not found: {ref}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
out = Path(args.out)
|
||||
out.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
try:
|
||||
from f5_tts.api import F5TTS
|
||||
except ImportError as e:
|
||||
print("f5-tts not installed. Run: ./scripts/setup_f5tts.sh", file=sys.stderr)
|
||||
print(e, file=sys.stderr)
|
||||
return 1
|
||||
|
||||
tts = F5TTS(model=args.model)
|
||||
tts.infer(
|
||||
ref_file=str(ref),
|
||||
ref_text=args.ref_text,
|
||||
gen_text=args.gen_text,
|
||||
file_wave=str(out),
|
||||
remove_silence=True,
|
||||
)
|
||||
print(f"OK: {out}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user