Skip to content

v0.4.40

Compare
Choose a tag to compare
@KoljaB KoljaB released this 06 Jan 12:07
· 2 commits to master since this release

RealtimeTTS v0.4.4 Release Notes

Configurable Playback Parameters

New Parameters: frames_per_buffer and playout_chunk_size

  • Purpose:

    • These new parameters provide finer control over audio playback buffering, which is especially useful for mitigating stuttering issues on Unix-based systems.
  • Details:

    1. frames_per_buffer:

      • Controls the number of audio frames processed per buffer by PyAudio.
      • Lower values reduce latency but increase CPU usage, while higher values reduce CPU load but increase latency.
      • Recommended Settings for Stuttering:
        • Start by setting frames_per_buffer to 256.
        • If issues persist, reduce it further to 128.

      Example:

      stream = TextToAudioStream(engine, frames_per_buffer=256)
    2. playout_chunk_size:

      • Specifies the size (in bytes) of audio chunks played out to the stream.
      • Works in conjunction with frames_per_buffer to optimize audio smoothness.
      • Defaults to dynamic calculation, but can be explicitly set for precise control.

      Example:

      stream = TextToAudioStream(engine, playout_chunk_size=1024)

How These Parameters Address Stuttering:

  • On Unix systems, default buffer sizes may cause sporadic stuttering during audio playback due to timing mismatches between the audio stream and system audio drivers.
  • By reducing frames_per_buffer to 256 or 128, the playback becomes more responsive and better aligned with system timing.
  • Adjusting playout_chunk_size further enhances playback smoothness by ensuring optimal chunk delivery to the audio stream.

Usage Examples

Basic Configuration:

from RealtimeTTS import TextToAudioStream, PiperEngine

engine = PiperEngine(piper_path="path/to/piper.exe", voice=my_voice)
stream = TextToAudioStream(
    engine=engine,
    frames_per_buffer=256,  # Start with 256 to reduce stuttering
    playout_chunk_size=1024 # Optional for further customization
)
stream.play()

Fine-Tuning for Stuttering:

  • If playback issues occur:
    1. Set frames_per_buffer to 256 (recommended starting point).
    2. Reduce to 128 if stuttering persists.
    3. Optionally adjust playout_chunk_size to a fixed value like 1024 or 512.

  • Backward Compatibility:
    • Defaults for frames_per_buffer and playout_chunk_size maintain compatibility with previous versions, requiring no changes for existing setups unless adjustments are needed.