TTS-Engines¶
Referenz für die verschiedenen Sprachsynthese-Engines.
Basis-Schnittstelle¶
text2speech.engines.base.TTSEngine
¶
Bases: Protocol
Protocol for TTS engine implementations.
Source code in text2speech/engines/base.py
synthesize(text, voice=None, speed=1.0)
¶
Synthesize speech from text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to synthesize. |
required |
voice
|
Optional[str]
|
Voice identifier. |
None
|
speed
|
float
|
Speech speed multiplier. |
1.0
|
Yields:
| Type | Description |
|---|---|
Tuple[Optional[str], Optional[str], Tensor]
|
Iterator[Tuple[Optional[str], Optional[str], torch.Tensor]]: Tuples of (graphemes, phonemes, audio_tensor). |
Source code in text2speech/engines/base.py
Kokoro Engine¶
text2speech.engines.kokoro.KokoroEngine
¶
TTS engine using the Kokoro model.
Source code in text2speech/engines/kokoro.py
__init__(lang_code='a')
¶
Initialize Kokoro engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lang_code
|
str
|
Language code for the pipeline. |
'a'
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If kokoro package is not installed. |
RuntimeError
|
If pipeline initialization fails. |
Source code in text2speech/engines/kokoro.py
synthesize(text, voice=None, speed=1.0)
¶
Synthesize speech using Kokoro.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to synthesize. |
required |
voice
|
Optional[str]
|
Voice identifier. |
None
|
speed
|
float
|
Speech speed multiplier. |
1.0
|
Yields:
| Type | Description |
|---|---|
Tuple[Optional[str], Optional[str], Tensor]
|
Iterator[Tuple[Optional[str], Optional[str], torch.Tensor]]: Tuples of (graphemes, phonemes, audio_tensor). |
Source code in text2speech/engines/kokoro.py
ElevenLabs Engine¶
text2speech.engines.elevenlabs.ElevenLabsEngine
¶
TTS engine using ElevenLabs API.
Source code in text2speech/engines/elevenlabs.py
__init__(api_key, model='eleven_multilingual_v2')
¶
Initialize ElevenLabs engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
ElevenLabs API key. |
required |
model
|
str
|
Model identifier. |
'eleven_multilingual_v2'
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If elevenlabs package is not installed. |
Source code in text2speech/engines/elevenlabs.py
synthesize(text, voice=None, speed=1.0)
¶
Synthesize speech using ElevenLabs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to synthesize. |
required |
voice
|
Optional[str]
|
Voice identifier. |
None
|
speed
|
float
|
Speech speed multiplier (currently ignored for ElevenLabs). |
1.0
|
Yields:
| Type | Description |
|---|---|
Tuple[Optional[str], Optional[str], Tensor]
|
Iterator[Tuple[Optional[str], Optional[str], torch.Tensor]]: Tuples of (graphemes, phonemes, audio_tensor). |