A Python package providing unified interfaces to various text-to-speech services. The package wraps multiple TTS providers behind a common async interface, making it easy to switch between different services or use them in parallel.
- Google Cloud TTS: High-quality multilingual speech synthesis using Google's advanced ML models
- Yandex SpeechKit: Yandex's speech synthesis service with support for Russian and other languages
- ElevenLabs: AI voice generation with high emotion control and voice cloning capabilities
- Listnr: Text-to-speech service with natural-sounding voices
- Murf: AI voice generator with support for multiple languages and styles
pip install git+https://github.com/VPetukhov/tts-wrappers.git
from tts_wrappers.synthesizers import GoogleSynthesizer
# Initialize Google TTS
synthesizer = GoogleSynthesizer(
voice_id="en-US-Polyglot-1",
language_code="en-us",
secret_file="path/to/service_account_key.json"
)
# Synthesize text (returns pydub.AudioSegment)
audio = await synthesizer.synthesize_text("Hello, world!")
from tts_wrappers.synthesizers import GoogleSynthesizer
synthesizer = GoogleSynthesizer(
voice_id="en-US-Polyglot-1",
language_code="en-us",
speaking_rate=1.0,
secret_file="secrets/service_account_key.json"
)
audio = await synthesizer.synthesize_text("Hello!", ssml=False)
from tts_wrappers.synthesizers import YandexSynthesizer
synthesizer = YandexSynthesizer(
api_key="your-api-key",
folder_id="your-folder-id",
language_code="ru-RU",
voice_id="lera",
speaking_rate=1.0
)
audio = await synthesizer.synthesize_text("Привет!")
from tts_wrappers.synthesizers import ElevenlabsSynthesizer
synthesizer = ElevenlabsSynthesizer(
api_key="your-api-key",
voice_id="voice-id" # Default: "y6EK3fBpbyHWYUj9UxcF" (Nay4 voice)
)
audio = await synthesizer.synthesize_text("Hello!")
All synthesizers implement the following interface:
class Synthesizer(ABC):
@abstractmethod
async def synthesize_text(self, text: str, **kwargs) -> pydub.AudioSegment:
"""Synthesize text to speech.
Args:
text: Text to synthesize
**kwargs: Additional synthesis parameters specific to each service
Returns:
AudioSegment with the synthesized speech
"""
pass
- Python 3.7+
- google-cloud-texttospeech
- yandex-speechkit
- pydub
- requests
Each service requires specific authentication:
- Google Cloud TTS: Requires a service account key JSON file
- Yandex SpeechKit: Requires API key and folder ID
- ElevenLabs: Requires API key
- Listnr: Requires API key
- Murf: Requires API key
MIT License