Skip to content

Commit

Permalink
Change defaults to text -> piper wav
Browse files Browse the repository at this point in the history
Remove API key warning. Small piper fixes.
  • Loading branch information
eliasbe committed Dec 16, 2024
1 parent 96b3f7a commit 934a51c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/icespeak/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ class Settings(BaseSettings):
extra="ignore",
)

DEFAULT_VOICE: str = Field(default="Gudrun", description="Default TTS voice if none is requested.")
DEFAULT_VOICE: str = Field(default="bui", description="Default TTS voice if none is requested.")
DEFAULT_VOICE_SPEED: float = Field(
default=1.0,
le=MAX_SPEED,
ge=MIN_SPEED,
description="Default TTS voice speed.",
)
DEFAULT_TEXT_FORMAT: TextFormats = Field(
default=TextFormats.SSML,
default=TextFormats.TEXT,
description="Default format to interpret input text as.",
)
DEFAULT_AUDIO_FORMAT: AudioFormats = Field(default=AudioFormats.MP3, description="Default audio output format.")
DEFAULT_AUDIO_FORMAT: AudioFormats = Field(default=AudioFormats.WAV, description="Default audio output format.")

AUDIO_DIR: Optional[Path] = Field(
default=None,
Expand Down
3 changes: 0 additions & 3 deletions src/icespeak/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ def _setup_voices() -> tuple[VoicesT, ServicesT]:

VOICES, SERVICES = _setup_voices()

assert VOICES, """No voices available. Make sure to provide an API key \
for at least one speech synthesis engine in your ICESPEAK_KEYS_DIR directory."""


_T = TypeVar("_T")

Expand Down
16 changes: 10 additions & 6 deletions src/icespeak/voices/piper_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@
class PiperTTSVoice(BaseVoice):
_NAME: str = "Piper"
_VOICES: ModuleVoicesT = {
"bui": {"id": "bui-medium", "lang": "is_IS", "style": "male"},
"salka": {"id": "salka-medium", "lang": "is_IS", "style": "female"},
"steinn": {"id": "steinn-medium", "lang": "is_IS", "style": "male"},
"ugla": {"id": "ugla-medium", "lang": "is_IS", "style": "female"},
"bui": {"id": "bui-medium", "lang": "is-IS", "style": "male"},
"salka": {"id": "salka-medium", "lang": "is-IS", "style": "female"},
"steinn": {"id": "steinn-medium", "lang": "is-IS", "style": "male"},
"ugla": {"id": "ugla-medium", "lang": "is-IS", "style": "female"},
}
_AUDIO_FORMATS: ModuleAudioFormatsT = frozenset({"pcm", "wav"})

@override
def __init__(self) -> None:
self._avail = True

@property
@override
def name(self) -> str:
Expand Down Expand Up @@ -80,7 +84,7 @@ def text_to_speech(self, text: str, options: TTSOptions, keys_override: Keys | N
outfile = SETTINGS.get_empty_file(options.audio_format)
audio_dir = SETTINGS.get_audio_dir()
voice = self.voices[options.voice]
model = f"{voice['lang']}-{voice['id']}"
model = f"{voice['lang'].replace('-','_')}-{voice['id']}"
data_dir = audio_dir / "Piper"
piper_args = {
"model": shlex.quote(str(model)),
Expand Down Expand Up @@ -139,4 +143,4 @@ def text_to_speech(self, text: str, options: TTSOptions, keys_override: Keys | N
return outfile


# TODO: Add option to use GPU. This requires onnxruntime-gpu, the --cuda flag and a functioning CUDA environment.
# NOTE: Possible to add option to use GPU. This requires onnxruntime-gpu, the --cuda flag and a functioning CUDA environment.

0 comments on commit 934a51c

Please sign in to comment.