Skip to content

Refactor: Remove single-use TTS wrapper functions #182

@basnijholt

Description

@basnijholt

Problem

The TTS synthesizer wrappers in agent_cli/services/tts.py are thin wrappers that only add **_kwargs to absorb unused config arguments:

async def _synthesize_speech_gemini(
    *,
    text: str,
    gemini_tts_cfg: config.GeminiTTS,
    logger: logging.Logger,
    **_kwargs: object,
) -> bytes | None:
    """Synthesize speech from text using Gemini TTS."""
    return await synthesize_speech_gemini(text=text, gemini_tts_cfg=gemini_tts_cfg, logger=logger)

This exists because the caller passes all TTS configs:

audio_data = await synthesizer(
    text=text,
    wyoming_tts_cfg=wyoming_tts_cfg,
    openai_tts_cfg=openai_tts_cfg,
    kokoro_tts_cfg=kokoro_tts_cfg,
    gemini_tts_cfg=gemini_tts_cfg,
    logger=logger,
)

Proposal

Add **_kwargs directly to the base functions in services/__init__.py and call them directly, removing the wrapper indirection.

Applies to:

  • _synthesize_speech_geminisynthesize_speech_gemini
  • _synthesize_speech_openaisynthesize_speech_openai

Benefits

  • Fewer indirections
  • Follows "keep it DRY" and "simplest solution" principles

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions