Skip to content

VPetukhov/tts-wrappers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

TTS Wrappers

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.

Supported Services

  • 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

Installation

pip install git+https://github.com/VPetukhov/tts-wrappers.git

Usage

Basic Example

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!")

Service-Specific Examples

Google Cloud TTS

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)

Yandex SpeechKit

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("Привет!")

ElevenLabs

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!")

Common Interface

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

Requirements

  • Python 3.7+
  • google-cloud-texttospeech
  • yandex-speechkit
  • pydub
  • requests

Authentication

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

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages