Add CLI tool
This commit is contained in:
65
README.md
65
README.md
@@ -46,7 +46,54 @@ The WebUI supports muliple languages and voices. First, follow the installation
|
|||||||
python app.py
|
python app.py
|
||||||
```
|
```
|
||||||
|
|
||||||
### English with Multi Accents
|
### CLI
|
||||||
|
|
||||||
|
You may use the MeloTTS CLI to interact with MeloTTS. The CLI may be invoked using either `melotts` or `melo`. Here are some examples:
|
||||||
|
|
||||||
|
**Read English text:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
melo "Text to read" output.wav
|
||||||
|
```
|
||||||
|
|
||||||
|
**Specify a language:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
melo "Text to read" output.wav --language EN
|
||||||
|
```
|
||||||
|
|
||||||
|
**Specify a speaker:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
melo "Text to read" output.wav --language EN --speaker EN-US
|
||||||
|
melo "Text to read" output.wav --language EN --speaker EN-AU
|
||||||
|
```
|
||||||
|
|
||||||
|
The available speakers are: `EN-Default`, `EN-US`, `EN-BR`, `EN-INDIA` `EN-AU`.
|
||||||
|
|
||||||
|
**Specify a speed:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
melo "Text to read" output.wav --language EN --speaker EN-US --speed 1.5
|
||||||
|
melo "Text to read" output.wav --speed 1.5
|
||||||
|
```
|
||||||
|
|
||||||
|
**Use a different language:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
melo "语音合成领域近年来发展迅速" zh.wav -l ZH
|
||||||
|
```
|
||||||
|
|
||||||
|
The full API documentation may be found using:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
melo --help
|
||||||
|
```
|
||||||
|
|
||||||
|
### Python API
|
||||||
|
|
||||||
|
#### English with Multi Accents
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from melo.api import TTS
|
from melo.api import TTS
|
||||||
|
|
||||||
@@ -103,7 +150,8 @@ output_path = 'es.wav'
|
|||||||
model.tts_to_file(text, speaker_ids['ES'], output_path, speed=speed)
|
model.tts_to_file(text, speaker_ids['ES'], output_path, speed=speed)
|
||||||
```
|
```
|
||||||
|
|
||||||
### French
|
#### French
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from melo.api import TTS
|
from melo.api import TTS
|
||||||
|
|
||||||
@@ -119,7 +167,8 @@ output_path = 'fr.wav'
|
|||||||
model.tts_to_file(text, speaker_ids['FR'], output_path, speed=speed)
|
model.tts_to_file(text, speaker_ids['FR'], output_path, speed=speed)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Chinese
|
#### Chinese
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from melo.api import TTS
|
from melo.api import TTS
|
||||||
|
|
||||||
@@ -135,7 +184,8 @@ output_path = 'zh.wav'
|
|||||||
model.tts_to_file(text, speaker_ids['ZH'], output_path, speed=speed)
|
model.tts_to_file(text, speaker_ids['ZH'], output_path, speed=speed)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Japanese
|
#### Japanese
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from melo.api import TTS
|
from melo.api import TTS
|
||||||
|
|
||||||
@@ -151,7 +201,8 @@ output_path = 'jp.wav'
|
|||||||
model.tts_to_file(text, speaker_ids['JP'], output_path, speed=speed)
|
model.tts_to_file(text, speaker_ids['JP'], output_path, speed=speed)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Korean
|
#### Korean
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from melo.api import TTS
|
from melo.api import TTS
|
||||||
|
|
||||||
@@ -168,7 +219,9 @@ model.tts_to_file(text, speaker_ids['KR'], output_path, speed=speed)
|
|||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This library is under MIT License, which means it is free for both commercial and non-commercial use.
|
This library is under MIT License, which means it is free for both commercial and non-commercial use.
|
||||||
|
|
||||||
## Acknowledgement
|
## Acknowledgements
|
||||||
|
|
||||||
This implementation is based on several excellent projects, [TTS](https://github.com/coqui-ai/TTS), [VITS](https://github.com/jaywalnut310/vits), [VITS2](https://github.com/daniilrobnikov/vits2) and [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2). We appreciate their awesome work!
|
This implementation is based on several excellent projects, [TTS](https://github.com/coqui-ai/TTS), [VITS](https://github.com/jaywalnut310/vits), [VITS2](https://github.com/daniilrobnikov/vits2) and [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2). We appreciate their awesome work!
|
||||||
|
|||||||
28
melo/main.py
Normal file
28
melo/main.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import click
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
@click.command
|
||||||
|
@click.argument('text')
|
||||||
|
@click.argument('output_path')
|
||||||
|
@click.option('--language', '-l', default='EN', help='Language, defaults to English', type=click.Choice(['EN', 'ES', 'FR', 'ZH', 'JP', 'KR'], case_sensitive=False))
|
||||||
|
@click.option('--speaker', '-spk', default='EN-Default', help='Speaker ID, only for English, leave empty for default, ignored if not English. If English, defaults to "EN-Default"', type=click.Choice(['EN-Default', 'EN-US', 'EN-BR', 'EN-INDIA', 'EN-AU']))
|
||||||
|
@click.option('--speed', '-s', default=1.0, help='Speed, defaults to 1.0', type=float)
|
||||||
|
@click.option('--device', '-d', default='auto', help='Device, defaults to auto')
|
||||||
|
def main(text, output_path, language, speaker, speed, device):
|
||||||
|
language = language.upper()
|
||||||
|
if language == '': language = 'EN'
|
||||||
|
if speaker == '': speaker = None
|
||||||
|
if (not language == 'EN') and speaker:
|
||||||
|
warnings.warn('You specified a speaker but the language is English.')
|
||||||
|
from melo.api import TTS
|
||||||
|
model = TTS(language=language, device=device)
|
||||||
|
speaker_ids = model.hps.data.spk2id
|
||||||
|
if language == 'EN':
|
||||||
|
if not speaker: speaker = 'EN-Default'
|
||||||
|
spkr = speaker_ids[speaker]
|
||||||
|
else:
|
||||||
|
spkr = speaker_ids[list(speaker_ids.keys())[0]]
|
||||||
|
model.tts_to_file(text, spkr, output_path, speed=speed)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user