mirror of
https://github.com/Paillat-dev/viralfactory.git
synced 2026-01-02 17:24:54 +00:00
Some stuff
This commit is contained in:
10
src/engines/BaseEngine.py
Normal file
10
src/engines/BaseEngine.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from abc import ABC, abstractmethod
|
||||
import gradio as gr
|
||||
|
||||
class BaseEngine(ABC):
|
||||
options: list
|
||||
name: str
|
||||
description: str
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
10
src/engines/TTSEngine/BaseTTSEngine.py
Normal file
10
src/engines/TTSEngine/BaseTTSEngine.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from ..BaseEngine import BaseEngine
|
||||
|
||||
|
||||
class BaseTTSEngine(BaseEngine):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def synthesize(self, text: str, path: str) -> str:
|
||||
pass
|
||||
111
src/engines/TTSEngine/CoquiTTSEngine.py
Normal file
111
src/engines/TTSEngine/CoquiTTSEngine.py
Normal file
@@ -0,0 +1,111 @@
|
||||
import gradio as gr
|
||||
import TTS
|
||||
import os
|
||||
import torch
|
||||
|
||||
from .BaseTTSEngine import BaseTTSEngine
|
||||
|
||||
|
||||
class CoquiTTSEngine(BaseTTSEngine):
|
||||
voices = [
|
||||
"Claribel Dervla",
|
||||
"Daisy Studious",
|
||||
"Gracie Wise",
|
||||
"Tammie Ema",
|
||||
"Alison Dietlinde",
|
||||
"Ana Florence",
|
||||
"Annmarie Nele",
|
||||
"Asya Anara",
|
||||
"Brenda Stern",
|
||||
"Gitta Nikolina",
|
||||
"Henriette Usha",
|
||||
"Sofia Hellen",
|
||||
"Tammy Grit",
|
||||
"Tanja Adelina",
|
||||
"Vjollca Johnnie",
|
||||
"Andrew Chipper",
|
||||
"Badr Odhiambo",
|
||||
"Dionisio Schuyler",
|
||||
"Royston Min",
|
||||
"Viktor Eka",
|
||||
"Abrahan Mack",
|
||||
"Adde Michal",
|
||||
"Baldur Sanjin",
|
||||
"Craig Gutsy",
|
||||
"Damien Black",
|
||||
"Gilberto Mathias",
|
||||
"Ilkin Urbano",
|
||||
"Kazuhiko Atallah",
|
||||
"Ludvig Milivoj",
|
||||
"Suad Qasim",
|
||||
"Torcull Diarmuid",
|
||||
"Viktor Menelaos",
|
||||
"Zacharie Aimilios",
|
||||
"Nova Hogarth",
|
||||
"Maja Ruoho",
|
||||
"Uta Obando",
|
||||
"Lidiya Szekeres",
|
||||
"Chandra MacFarland",
|
||||
"Szofi Granger",
|
||||
"Camilla Holmström",
|
||||
"Lilya Stainthorpe",
|
||||
"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 = "Coqui TTS"
|
||||
description = "Coqui TTS engine."
|
||||
languages = [
|
||||
"en", # English
|
||||
"es", # Spanish
|
||||
"fr", # French
|
||||
"de", # German
|
||||
"it", # Italian
|
||||
"pt", # Portuguese
|
||||
"pl", # Polish
|
||||
"tr", # Turkish
|
||||
"ru", # Russian
|
||||
"nl", # Dutch
|
||||
"cs", # Czech
|
||||
"ar", # Arabic
|
||||
"zh-cn", # Chinese (Simplified)
|
||||
"ja", # Japanese
|
||||
"hu", # Hungarian
|
||||
"ko", # Korean
|
||||
"hi", # Hindi
|
||||
]
|
||||
options = [
|
||||
gr.Dropdown(
|
||||
voices, value=voices[0], label="voice", max_choices=1
|
||||
),
|
||||
gr.Dropwdown(
|
||||
languages, value=languages[0], label="language", max_choices=1
|
||||
),
|
||||
]
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
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)
|
||||
|
||||
def synthesize(self, text: str, path: str) -> str:
|
||||
voice = self.options[0].value
|
||||
language = self.options[1].value
|
||||
self.tts.tts_to_file(text=text, file_path=path, lang=language, speaker=voice)
|
||||
return path
|
||||
13
src/engines/TTSEngine/ElevenLabsTTSEngine.py
Normal file
13
src/engines/TTSEngine/ElevenLabsTTSEngine.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from .BaseTTSEngine import AbstractTTSEngine
|
||||
import gradio as gr
|
||||
|
||||
class ElevenLabsTTSEngine(AbstractTTSEngine):
|
||||
options = [gr.Radio(["Neutral", "Happy", "Sad"], label="emotion")]
|
||||
name = "ElevenLabs"
|
||||
description = "ElevenLabs TTS engine."
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def synthesize(self, text: str, path: str) -> str:
|
||||
pass
|
||||
3
src/engines/TTSEngine/__init__.py
Normal file
3
src/engines/TTSEngine/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .BaseTTSEngine import BaseTTSEngine
|
||||
from .CoquiTTSEngine import CoquiTTSEngine
|
||||
from .ElevenLabsTTSEngine import ElevenLabsTTSEngine
|
||||
2
src/engines/__init__.py
Normal file
2
src/engines/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import TTSEngine
|
||||
from .BaseEngine import BaseEngine
|
||||
6
src/engines/engines.json
Normal file
6
src/engines/engines.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"TTSEngine": [
|
||||
"CoquiTTSEngine",
|
||||
"ElevenLabsTTSEngine"
|
||||
]
|
||||
}
|
||||
4
src/engines/script/AbstractScriptEngine.py
Normal file
4
src/engines/script/AbstractScriptEngine.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from src.engines.BaseEngine import AbstractEngine
|
||||
|
||||
class AbstractScriptEngine(AbstractEngine):
|
||||
pass
|
||||
6
src/engines/script/ComicalScriptEngine.py
Normal file
6
src/engines/script/ComicalScriptEngine.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from AbstractScriptEngine import AbstractScriptEngine
|
||||
|
||||
class ComicalScriptEngine(AbstractScriptEngine):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.options = {"comicality": ["Low", "Medium", "High"]}
|
||||
6
src/engines/script/DrammaticScriptEngine.py
Normal file
6
src/engines/script/DrammaticScriptEngine.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from AbstractScriptEngine import AbstractScriptEngine
|
||||
|
||||
class DramaticScriptEngine(AbstractScriptEngine):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.options = {"tone": ["Serious", "Light-hearted"]}
|
||||
Reference in New Issue
Block a user