v0.4.40
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:
-
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
to256
. - If issues persist, reduce it further to
128
.
- Start by setting
Example:
stream = TextToAudioStream(engine, frames_per_buffer=256)
-
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
to256
or128
, 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:
- Set
frames_per_buffer
to256
(recommended starting point). - Reduce to
128
if stuttering persists. - Optionally adjust
playout_chunk_size
to a fixed value like1024
or512
.
- Set
- Backward Compatibility:
- Defaults for
frames_per_buffer
andplayout_chunk_size
maintain compatibility with previous versions, requiring no changes for existing setups unless adjustments are needed.
- Defaults for