Spaces:
Running
Running
Add OpenVoice VC models
Browse files- app.py +13 -3
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -8,6 +8,12 @@ CUDA = torch.cuda.is_available()
|
|
| 8 |
|
| 9 |
REPO_ID = "ayymen/Coqui-TTS-Vits-shi"
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
my_title = "ⴰⴹⵕⵉⵚ ⵙ ⵉⵎⵙⵍⵉ - Tamazight Text-to-Speech"
|
| 12 |
my_description = "This model is based on [VITS](https://github.com/jaywalnut310/vits), thanks to 🐸 [Coqui.ai](https://coqui.ai/)."
|
| 13 |
|
|
@@ -21,6 +27,7 @@ my_examples = [
|
|
| 21 |
my_inputs = [
|
| 22 |
gr.Textbox(lines=5, label="Input Text", placeholder="The only available characters are: ⴰⴱⴳⴷⴹⴻⴼⴽⵀⵃⵄⵅⵇⵉⵊⵍⵎⵏⵓⵔⵕⵖⵙⵚⵛⵜⵟⵡⵢⵣⵥⵯ !,.:?"),
|
| 23 |
gr.Audio(type="filepath", label="Speaker audio for voice cloning (optional)"),
|
|
|
|
| 24 |
gr.Checkbox(label="Split Sentences (each sentence will be generated separately)", value=True)
|
| 25 |
]
|
| 26 |
|
|
@@ -31,19 +38,22 @@ config_path = hf_hub_download(repo_id=REPO_ID, filename="config.json")
|
|
| 31 |
|
| 32 |
api = TTS(model_path=best_model_path, config_path=config_path).to("cuda" if CUDA else "cpu")
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
-
def tts(text: str, speaker_wav: str = None, split_sentences: bool = True):
|
| 38 |
# replace oov characters
|
| 39 |
text = text.replace("\n", ". ")
|
| 40 |
text = text.replace("(", ",")
|
| 41 |
text = text.replace(")", ",")
|
|
|
|
| 42 |
text = text.replace(";", ",")
|
| 43 |
text = text.replace("-", " ")
|
| 44 |
|
| 45 |
with tempfile.NamedTemporaryFile(suffix = ".wav", delete = False) as fp:
|
| 46 |
if speaker_wav:
|
|
|
|
| 47 |
api.tts_with_vc_to_file(text, speaker_wav=speaker_wav, file_path=fp.name, split_sentences=split_sentences)
|
| 48 |
else:
|
| 49 |
api.tts_to_file(text, file_path=fp.name, split_sentences=split_sentences)
|
|
|
|
| 8 |
|
| 9 |
REPO_ID = "ayymen/Coqui-TTS-Vits-shi"
|
| 10 |
|
| 11 |
+
VOICE_CONVERSION_MODELS = {
|
| 12 |
+
'freevc24': 'voice_conversion_models/multilingual/vctk/freevc24'
|
| 13 |
+
'openvoice_v1': 'voice_conversion_models/multilingual/multi-dataset/openvoice_v1',
|
| 14 |
+
'openvoice_v2': 'voice_conversion_models/multilingual/multi-dataset/openvoice_v2',
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
my_title = "ⴰⴹⵕⵉⵚ ⵙ ⵉⵎⵙⵍⵉ - Tamazight Text-to-Speech"
|
| 18 |
my_description = "This model is based on [VITS](https://github.com/jaywalnut310/vits), thanks to 🐸 [Coqui.ai](https://coqui.ai/)."
|
| 19 |
|
|
|
|
| 27 |
my_inputs = [
|
| 28 |
gr.Textbox(lines=5, label="Input Text", placeholder="The only available characters are: ⴰⴱⴳⴷⴹⴻⴼⴽⵀⵃⵄⵅⵇⵉⵊⵍⵎⵏⵓⵔⵕⵖⵙⵚⵛⵜⵟⵡⵢⵣⵥⵯ !,.:?"),
|
| 29 |
gr.Audio(type="filepath", label="Speaker audio for voice cloning (optional)"),
|
| 30 |
+
gr.Dropdown(label="Voice Conversion Model", choices=list(VOICE_CONVERSION_MODELS.keys())),
|
| 31 |
gr.Checkbox(label="Split Sentences (each sentence will be generated separately)", value=True)
|
| 32 |
]
|
| 33 |
|
|
|
|
| 38 |
|
| 39 |
api = TTS(model_path=best_model_path, config_path=config_path).to("cuda" if CUDA else "cpu")
|
| 40 |
|
| 41 |
+
# pre-download voice conversion models
|
| 42 |
+
for model in VOICE_CONVERSION_MODELS.values():
|
| 43 |
+
api.load_vc_model_by_name(model, gpu=CUDA)
|
| 44 |
|
| 45 |
+
def tts(text: str, speaker_wav: str = None, voice_cv_model: str = 'freevc24', split_sentences: bool = True):
|
| 46 |
# replace oov characters
|
| 47 |
text = text.replace("\n", ". ")
|
| 48 |
text = text.replace("(", ",")
|
| 49 |
text = text.replace(")", ",")
|
| 50 |
+
text = text.replace('"', ",")
|
| 51 |
text = text.replace(";", ",")
|
| 52 |
text = text.replace("-", " ")
|
| 53 |
|
| 54 |
with tempfile.NamedTemporaryFile(suffix = ".wav", delete = False) as fp:
|
| 55 |
if speaker_wav:
|
| 56 |
+
api.load_vc_model_by_name(VOICE_CONVERSION_MODELS[voice_cv_model], gpu=CUDA)
|
| 57 |
api.tts_with_vc_to_file(text, speaker_wav=speaker_wav, file_path=fp.name, split_sentences=split_sentences)
|
| 58 |
else:
|
| 59 |
api.tts_to_file(text, file_path=fp.name, split_sentences=split_sentences)
|
requirements.txt
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
coqui-tts==0.
|
|
|
|
| 1 |
+
coqui-tts==0.25.0
|