mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 18:45:00 +00:00
feat(tts): Add Kokoro backend (#4616)
* feat(kokoro): Add new TTS backend Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Add kokoro to images Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Support combined voices Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Ignore pt and onnx Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Add plbert and istfnet Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
de4aa9fb1d
commit
acb2eb23c8
19 changed files with 1303 additions and 3 deletions
16
backend/python/kokoro/plbert.py
Normal file
16
backend/python/kokoro/plbert.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
# https://huggingface.co/hexgrad/Kokoro-82M/blob/main/plbert.py
|
||||
# https://github.com/yl4579/StyleTTS2/blob/main/Utils/PLBERT/util.py
|
||||
from transformers import AlbertConfig, AlbertModel
|
||||
|
||||
class CustomAlbert(AlbertModel):
|
||||
def forward(self, *args, **kwargs):
|
||||
# Call the original forward method
|
||||
outputs = super().forward(*args, **kwargs)
|
||||
# Only return the last_hidden_state
|
||||
return outputs.last_hidden_state
|
||||
|
||||
def load_plbert():
|
||||
plbert_config = {'vocab_size': 178, 'hidden_size': 768, 'num_attention_heads': 12, 'intermediate_size': 2048, 'max_position_embeddings': 512, 'num_hidden_layers': 12, 'dropout': 0.1}
|
||||
albert_base_configuration = AlbertConfig(**plbert_config)
|
||||
bert = CustomAlbert(albert_base_configuration)
|
||||
return bert
|
Loading…
Add table
Add a link
Reference in a new issue