Kokoro working, updated interface
This commit is contained in:
+41
-10
@@ -14,7 +14,7 @@ corresponding console script is not available in the current environment.
|
||||
"""
|
||||
|
||||
from .tts_generic import GenericTTSBackend
|
||||
from . import PathLike
|
||||
from . import log, PathLike
|
||||
|
||||
class AedocwBackend(GenericTTSBackend):
|
||||
"""Generic aedocw backend wrapper.
|
||||
@@ -33,10 +33,17 @@ class AedocwBackend(GenericTTSBackend):
|
||||
"speaker": "--speaker",
|
||||
"voice": "--speaker",
|
||||
"language": "--language",
|
||||
"cover": "--cover",
|
||||
}
|
||||
INTERMEDIATE_TXT = True
|
||||
INTERMEDIATE_CALL = GenericTTSBackend._replace_map
|
||||
|
||||
|
||||
def gen_input_flag(self, input_path) -> list[str]:
|
||||
"""Return backend flag for input file or directory."""
|
||||
p = self._normalize_path(input_path)
|
||||
return [str(p)] # epub2tts-edge expects a single path, no flag
|
||||
|
||||
gen_output_flag = None
|
||||
|
||||
|
||||
|
||||
@@ -48,15 +55,10 @@ class AedocwEpub2TTS(AedocwBackend):
|
||||
class AedocwEpub2TTSEdge(AedocwBackend):
|
||||
"""Backend configured for github.com/aedocw/epub2tts-edge."""
|
||||
DEFAULT_SPEAKER = "en-US-AndrewNeural"
|
||||
CMD = "epub2tts-edge"
|
||||
CMD = ["-c", "from epub2tts_edge import main;main()"]
|
||||
REPO = "epub2tts-edge"
|
||||
|
||||
def gen_input_flag(self, input_path) -> list[str]:
|
||||
"""Return backend flag for input file or directory."""
|
||||
p = self._normalize_path(input_path)
|
||||
return [str(p)] # epub2tts-edge expects a single path, no flag
|
||||
|
||||
gen_output_flag = None
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -73,10 +75,39 @@ class AedocwChatterbox(AedocwBackend):
|
||||
|
||||
class AedocwKokoro(AedocwBackend):
|
||||
"""Backend configured for github.com/aedocw/epub2tts-kokoro."""
|
||||
DEFAULT_SPEAKER = "af_heart"
|
||||
#DEFAULT_SPEAKER = "af_heart"
|
||||
DEFAULT_SPEAKER = "am_liam"
|
||||
CMD = ["-c", "from epub2tts_kokoro import main;main()"]
|
||||
REPO = "epub2tts-kokoro"
|
||||
FLAGS = {
|
||||
"--speaker": "voice", # str, default="af_heart"
|
||||
"--cover": "cover", # str, default=None
|
||||
"--paragraphpause": "long_pause", # int, default=600 (ms)
|
||||
"--speed": "speed", # float, default=1.3
|
||||
}
|
||||
DEFAULT_FLAGS = {
|
||||
"voice": "am_liam",
|
||||
"cover": None,
|
||||
"long_pause": 600,
|
||||
"speed": 1.3,
|
||||
}
|
||||
|
||||
|
||||
|
||||
def get_speakers(self) -> list[str]:
|
||||
"""Return list of available speakers."""
|
||||
return ["af_heart", "af_joy", "af_sad", "af_angry", "af_fear", "af_surprise"]
|
||||
|
||||
def gen_speaker_samples(
|
||||
self,
|
||||
samples: list =None,
|
||||
output_path: PathLike=None,
|
||||
) -> list[str]:
|
||||
"""Generate sample speakers audio in output_path."""
|
||||
result = self._build_command("gen_samples.py", *samples, output_path=output_path)
|
||||
return [str(self._normalize_path(s)) for s in samples]
|
||||
|
||||
|
||||
class Epub2TTS(AedocwBackend):
|
||||
"""Backward-compatible chatterbox backend wrapper."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user