Skip to content

TTSProvider

Sub classes

Name Children Inherits
EdgeTTSProvider
anyvoice.providers.edge
TTS provider using Microsoft Edge's free TTS service.
    OpenAITTSProvider
    anyvoice.providers.openai
    TTS provider using OpenAI's Text-to-Speech API.

      Base classes

      Name Children Inherits
      ABC
      abc
      Helper class that provides a standard way to create an ABC using

      ⋔ Inheritance diagram

      graph TD
        2851390888["base.TTSProvider"]
        925645236["abc.ABC"]
        2751680898["builtins.object"]
        925645236 --> 2851390888
        2751680898 --> 925645236

      🛈 DocStrings

      Bases: ABC

      Abstract base class for TTS providers.

      Providers hold credentials and client configuration, and act as factories for lightweight sessions.

      Usage

      provider = OpenAITTSProvider(api_key="...") session = provider.session(voice="nova", speed=1.0)

      Source code in src/anyvoice/base.py
      class TTSProvider(ABC):
          """Abstract base class for TTS providers.
      
          Providers hold credentials and client configuration, and act
          as factories for lightweight sessions.
      
          Usage:
              provider = OpenAITTSProvider(api_key="...")
              session = provider.session(voice="nova", speed=1.0)
          """
      
          @abstractmethod
          def session(self, **config: Any) -> TTSSession:
              """Create a new synthesis session with the given configuration.
      
              Args:
                  **config: Provider-specific configuration (voice, speed, etc.).
      
              Returns:
                  A new TTSSession configured with the given parameters.
              """
              ...
      

      session abstractmethod

      session(**config: Any) -> TTSSession
      

      Create a new synthesis session with the given configuration.

      Parameters:

      Name Type Description Default
      **config Any

      Provider-specific configuration (voice, speed, etc.).

      {}

      Returns:

      Type Description
      TTSSession

      A new TTSSession configured with the given parameters.

      Source code in src/anyvoice/base.py
      @abstractmethod
      def session(self, **config: Any) -> TTSSession:
          """Create a new synthesis session with the given configuration.
      
          Args:
              **config: Provider-specific configuration (voice, speed, etc.).
      
          Returns:
              A new TTSSession configured with the given parameters.
          """
          ...
      

      :fa-brands-github: Show source on GitHub