This commit is contained in:
2024-02-14 17:49:51 +01:00
parent 79d81b96b1
commit 0594458865
22 changed files with 223 additions and 124 deletions

View File

@@ -7,4 +7,4 @@ class BaseTTSEngine(BaseEngine):
@abstractmethod
def synthesize(self, text: str, path: str) -> str:
pass
pass

View File

@@ -1,7 +1,9 @@
import gradio as gr
import TTS
# import TTS
import os
import torch
# import torch
from .BaseTTSEngine import BaseTTSEngine
@@ -88,20 +90,7 @@ class CoquiTTSEngine(BaseTTSEngine):
"ko", # Korean
"hi", # Hindi
]
options = [
{
"type": "dropdown",
"label": "Voice",
"choices": voices,
"max": 1,
},
{
"type": "dropdown",
"label": "Language",
"choices": languages,
"max": 1,
},
]
num_options = 2
def __init__(self, options: list):
super().__init__()
@@ -110,10 +99,28 @@ class CoquiTTSEngine(BaseTTSEngine):
self.language = options[1][0]
os.environ["COQUI_TOS_AGREED"] = "1"
self.tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2")
device = "cuda" if torch.cuda.is_available() else "cpu"
self.tts.to(device)
# self.tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2")
# device = "cuda" if torch.cuda.is_available() else "cpu"
# self.tts.to(device)
def synthesize(self, text: str, path: str) -> str:
self.tts.tts_to_file(text=text, file_path=path, lang=self.language, speaker=self.voice)
return path
# self.tts.tts_to_file(text=text, file_path=path, lang=self.language, speaker=self.voice)
return path
@classmethod
def get_options(cls) -> list:
return [
gr.Dropdown(
label="Voice",
choices=cls.voices,
max_choices=1,
value=cls.voices[0],
),
gr.Dropdown(
label="Language",
choices=cls.languages,
max_choices=1,
value=cls.languages[0],
),
]

View File

@@ -1,38 +1,19 @@
from .BaseTTSEngine import BaseTTSEngine
import gradio as gr
class ElevenLabsTTSEngine(BaseTTSEngine):
options = [
{
"type": "dropdown",
"label": "Voice",
"choices": [
"Zofija Kendrick",
"Narelle Moon",
"Barbora MacLean",
"Alexandra Hisakawa",
"Alma María",
"Rosemary Okafor",
"Ige Behringer",
"Filip Traverse",
"Damjan Chapman",
"Wulf Carlevaro",
"Aaron Dreschner",
"Kumar Dahl",
"Eugenio Mataracı",
"Ferran Simen",
"Xavier Hayasaka",
"Luis Moray",
"Marcos Rudaski",
],
}
]
name = "ElevenLabs"
description = "ElevenLabs TTS engine."
num_options = 0
def __init__(self, options: list[list | tuple | str | int | float | bool | None]):
self.voice = options[0][0]
# self.voice = options[0][0]
super().__init__()
def synthesize(self, text: str, path: str) -> str:
pass
pass
@classmethod
def get_options(cls) -> list:
return []

View File

@@ -1,3 +1,3 @@
from .BaseTTSEngine import BaseTTSEngine
from .CoquiTTSEngine import CoquiTTSEngine
from .ElevenLabsTTSEngine import ElevenLabsTTSEngine
from .ElevenLabsTTSEngine import ElevenLabsTTSEngine