Download lgtm/cli.py from polyskill/LGTM: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/polyskill/LGTM/resolve/main/lgtm/cli.py
- Command line
-
hf download hf://polyskill/LGTM/lgtm/cli.py
-
curl -L -o cli.py https://huggingface.co/polyskill/LGTM/resolve/main/lgtm/cli.py
1.71 kB
| """Command line: python -m lgtm.cli --text "Xin chào" --lang vi --voice F1 --out out.wav [--ref ref.wav] [--backend onnx]""" | |
| import argparse | |
| def main(): | |
| ap = argparse.ArgumentParser(description="LGTM text-to-speech") | |
| ap.add_argument("--text", required=True) | |
| ap.add_argument("--lang", default="en", help="en es pt fr de it sv vi ja ko id") | |
| ap.add_argument("--voice", default="F1", help="preset (F1-F5, M1-M5) or voice .json") | |
| ap.add_argument("--ref", default=None, help="reference .wav to clone the voice from (overrides --voice)") | |
| ap.add_argument("--save_voice", default=None, help="save the cloned voice to this .json") | |
| ap.add_argument("--out", default="out.wav") | |
| ap.add_argument("--model", default=".", help="local model dir or Hugging Face repo id") | |
| ap.add_argument("--backend", choices=["torch", "onnx"], default="torch") | |
| ap.add_argument("--steps", type=int, default=8) | |
| ap.add_argument("--speed", type=float, default=1.05) | |
| ap.add_argument("--gpu", action="store_true", help="(onnx) use CUDAExecutionProvider") | |
| a = ap.parse_args() | |
| if a.backend == "onnx": | |
| from .onnx_inference import LGTMOnnx, save_voice_style | |
| tts = LGTMOnnx.from_pretrained(a.model, use_gpu=a.gpu) | |
| else: | |
| from .inference import LGTMTTS, save_voice_style | |
| tts = LGTMTTS.from_pretrained(a.model) | |
| voice = tts.clone_voice(a.ref) if a.ref else a.voice | |
| if a.ref and a.save_voice: | |
| save_voice_style(a.save_voice, voice) | |
| wav = tts.synthesize(a.text, lang=a.lang, voice=voice, steps=a.steps, speed=a.speed) | |
| tts.save_wav(wav, a.out) | |
| print(f"wrote {a.out} ({len(wav) / 44100:.2f} s)") | |
| if __name__ == "__main__": | |
| main() | |