feat: implement --force_lang advanced usage

This commit is contained in:
Ayo Ayco 2025-09-06 11:37:15 +02:00
parent 2b034f80c6
commit 06a2c2257b
2 changed files with 15 additions and 1 deletions

View file

@ -229,6 +229,12 @@ python tts.py --device cuda # will use the NVIDIA GPU
python tts.py --device xpu # will use the Intel GPU
```
If you want to use a voice for a different language text (e.g., Japanese voice for English text) you can use `--force_lang`
```bash
python tts.py -v jf_alpha "Hello there!" --force_lang a
```
## Demo Outputs
### Voice: pro (ah_heart)

10
tts.py
View file

@ -58,6 +58,13 @@ def parse_args():
default="pro",
help="Voice to use (pro, hot, asmr, brit)",
)
parser.add_argument(
"--force_lang",
required=False,
type=str,
default="a",
help="Force language code",
)
parser.add_argument(
"--input_file",
"-i",
@ -167,7 +174,8 @@ def main():
name = name.replace("\\", "_")
name = name.replace("/", "_")
lang_code = voice[0]
lang_code = args.force_lang if args.force_lang else voice[0]
pipeline = KPipeline(lang_code=lang_code, device=args.device, repo_id='hexgrad/Kokoro-82M')
'''