mirror of https://github.com/coqui-ai/TTS.git
Make style
This commit is contained in:
parent
a16360af85
commit
b2682d39c5
|
@ -82,7 +82,6 @@ class CS_API:
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SUPPORTED_LANGUAGES = ["en", "es", "de", "fr", "it", "pt", "pl", "tr", "ru", "nl", "cs", "ar", "zh-cn", "ja"]
|
SUPPORTED_LANGUAGES = ["en", "es", "de", "fr", "it", "pt", "pl", "tr", "ru", "nl", "cs", "ar", "zh-cn", "ja"]
|
||||||
|
|
||||||
def __init__(self, api_token=None, model="XTTS"):
|
def __init__(self, api_token=None, model="XTTS"):
|
||||||
|
@ -308,7 +307,11 @@ if __name__ == "__main__":
|
||||||
print(api.list_speakers_as_tts_models())
|
print(api.list_speakers_as_tts_models())
|
||||||
|
|
||||||
ts = time.time()
|
ts = time.time()
|
||||||
wav, sr = api.tts("It took me quite a long time to develop a voice.", language="en", speaker_name=api.speakers[0].name)
|
wav, sr = api.tts(
|
||||||
|
"It took me quite a long time to develop a voice.", language="en", speaker_name=api.speakers[0].name
|
||||||
|
)
|
||||||
print(f" [i] XTTS took {time.time() - ts:.2f}s")
|
print(f" [i] XTTS took {time.time() - ts:.2f}s")
|
||||||
|
|
||||||
filepath = api.tts_to_file(text="Hello world!", speaker_name=api.speakers[0].name, language="en", file_path="output.wav")
|
filepath = api.tts_to_file(
|
||||||
|
text="Hello world!", speaker_name=api.speakers[0].name, language="en", file_path="output.wav"
|
||||||
|
)
|
||||||
|
|
|
@ -562,15 +562,21 @@ class DPM_Solver:
|
||||||
if order == 3:
|
if order == 3:
|
||||||
K = steps // 3 + 1
|
K = steps // 3 + 1
|
||||||
if steps % 3 == 0:
|
if steps % 3 == 0:
|
||||||
orders = [3,] * (
|
orders = [
|
||||||
|
3,
|
||||||
|
] * (
|
||||||
K - 2
|
K - 2
|
||||||
) + [2, 1]
|
) + [2, 1]
|
||||||
elif steps % 3 == 1:
|
elif steps % 3 == 1:
|
||||||
orders = [3,] * (
|
orders = [
|
||||||
|
3,
|
||||||
|
] * (
|
||||||
K - 1
|
K - 1
|
||||||
) + [1]
|
) + [1]
|
||||||
else:
|
else:
|
||||||
orders = [3,] * (
|
orders = [
|
||||||
|
3,
|
||||||
|
] * (
|
||||||
K - 1
|
K - 1
|
||||||
) + [2]
|
) + [2]
|
||||||
elif order == 2:
|
elif order == 2:
|
||||||
|
@ -581,7 +587,9 @@ class DPM_Solver:
|
||||||
] * K
|
] * K
|
||||||
else:
|
else:
|
||||||
K = steps // 2 + 1
|
K = steps // 2 + 1
|
||||||
orders = [2,] * (
|
orders = [
|
||||||
|
2,
|
||||||
|
] * (
|
||||||
K - 1
|
K - 1
|
||||||
) + [1]
|
) + [1]
|
||||||
elif order == 1:
|
elif order == 1:
|
||||||
|
@ -1440,7 +1448,10 @@ class DPM_Solver:
|
||||||
model_prev_list[-1] = self.model_fn(x, t)
|
model_prev_list[-1] = self.model_fn(x, t)
|
||||||
elif method in ["singlestep", "singlestep_fixed"]:
|
elif method in ["singlestep", "singlestep_fixed"]:
|
||||||
if method == "singlestep":
|
if method == "singlestep":
|
||||||
(timesteps_outer, orders,) = self.get_orders_and_timesteps_for_singlestep_solver(
|
(
|
||||||
|
timesteps_outer,
|
||||||
|
orders,
|
||||||
|
) = self.get_orders_and_timesteps_for_singlestep_solver(
|
||||||
steps=steps,
|
steps=steps,
|
||||||
order=order,
|
order=order,
|
||||||
skip_type=skip_type,
|
skip_type=skip_type,
|
||||||
|
@ -1548,4 +1559,4 @@ def expand_dims(v, dims):
|
||||||
Returns:
|
Returns:
|
||||||
a PyTorch tensor with shape [N, 1, 1, ..., 1] and the total dimension is `dims`.
|
a PyTorch tensor with shape [N, 1, 1, ..., 1] and the total dimension is `dims`.
|
||||||
"""
|
"""
|
||||||
return v[(...,) + (None,) * (dims - 1)]
|
return v[(...,) + (None,) * (dims - 1)]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from functools import cached_property
|
||||||
|
|
||||||
import pypinyin
|
import pypinyin
|
||||||
import torch
|
import torch
|
||||||
|
@ -8,7 +9,6 @@ from hangul_romanize import Transliter
|
||||||
from hangul_romanize.rule import academic
|
from hangul_romanize.rule import academic
|
||||||
from num2words import num2words
|
from num2words import num2words
|
||||||
from tokenizers import Tokenizer
|
from tokenizers import Tokenizer
|
||||||
from functools import cached_property
|
|
||||||
|
|
||||||
from TTS.tts.layers.xtts.zh_num2words import TextNorm as zh_num2words
|
from TTS.tts.layers.xtts.zh_num2words import TextNorm as zh_num2words
|
||||||
|
|
||||||
|
@ -560,19 +560,22 @@ class VoiceBpeTokenizer:
|
||||||
@cached_property
|
@cached_property
|
||||||
def katsu(self):
|
def katsu(self):
|
||||||
import cutlet
|
import cutlet
|
||||||
|
|
||||||
return cutlet.Cutlet()
|
return cutlet.Cutlet()
|
||||||
|
|
||||||
def check_input_length(self, txt, lang):
|
def check_input_length(self, txt, lang):
|
||||||
limit = self.char_limits.get(lang, 250)
|
limit = self.char_limits.get(lang, 250)
|
||||||
if len(txt) > limit:
|
if len(txt) > limit:
|
||||||
print(f"[!] Warning: The text length exceeds the character limit of {limit} for language '{lang}', this might cause truncated audio.")
|
print(
|
||||||
|
f"[!] Warning: The text length exceeds the character limit of {limit} for language '{lang}', this might cause truncated audio."
|
||||||
|
)
|
||||||
|
|
||||||
def preprocess_text(self, txt, lang):
|
def preprocess_text(self, txt, lang):
|
||||||
if lang in {"ar", "cs", "de", "en", "es", "fr", "hu", "it", "nl", "pl", "pt", "ru", "tr", "zh", "zh-cn"}:
|
if lang in {"ar", "cs", "de", "en", "es", "fr", "hu", "it", "nl", "pl", "pt", "ru", "tr", "zh", "zh-cn"}:
|
||||||
txt = multilingual_cleaners(txt, lang)
|
txt = multilingual_cleaners(txt, lang)
|
||||||
if lang in {"zh", "zh-cn"}:
|
if lang in {"zh", "zh-cn"}:
|
||||||
txt = chinese_transliterate(txt)
|
txt = chinese_transliterate(txt)
|
||||||
elif lang == "ja":
|
elif lang == "ja":
|
||||||
txt = japanese_cleaners(txt, self.katsu)
|
txt = japanese_cleaners(txt, self.katsu)
|
||||||
elif lang == "ko":
|
elif lang == "ko":
|
||||||
txt = korean_cleaners(txt)
|
txt = korean_cleaners(txt)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import sys
|
||||||
import torch
|
import torch
|
||||||
import torch.nn.functional as F
|
import torch.nn.functional as F
|
||||||
import torch.utils.data
|
import torch.utils.data
|
||||||
|
|
||||||
from TTS.tts.models.xtts import load_audio
|
from TTS.tts.models.xtts import load_audio
|
||||||
|
|
||||||
torch.set_num_threads(1)
|
torch.set_num_threads(1)
|
||||||
|
|
|
@ -60,7 +60,9 @@ XTTS_CHECKPOINT = None # "/raid/edresson/dev/Checkpoints/XTTS_evaluation/xtts_s
|
||||||
|
|
||||||
|
|
||||||
# Training sentences generations
|
# Training sentences generations
|
||||||
SPEAKER_REFERENCE = ["tests/data/ljspeech/wavs/LJ001-0002.wav"] # speaker reference to be used in training test sentences
|
SPEAKER_REFERENCE = [
|
||||||
|
"tests/data/ljspeech/wavs/LJ001-0002.wav"
|
||||||
|
] # speaker reference to be used in training test sentences
|
||||||
LANGUAGE = config_dataset.language
|
LANGUAGE = config_dataset.language
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,9 @@ XTTS_CHECKPOINT = None # "/raid/edresson/dev/Checkpoints/XTTS_evaluation/xtts_s
|
||||||
|
|
||||||
|
|
||||||
# Training sentences generations
|
# Training sentences generations
|
||||||
SPEAKER_REFERENCE = ["tests/data/ljspeech/wavs/LJ001-0002.wav"] # speaker reference to be used in training test sentences
|
SPEAKER_REFERENCE = [
|
||||||
|
"tests/data/ljspeech/wavs/LJ001-0002.wav"
|
||||||
|
] # speaker reference to be used in training test sentences
|
||||||
LANGUAGE = config_dataset.language
|
LANGUAGE = config_dataset.language
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue