v0.4.40
KoljaB/RealtimeTTSv0.4.40Jan 6, 2025by KoljaB
AI Summary
Adds granular control over audio buffering parameters to help mitigate stuttering issues, particularly on Unix-based systems.
Key Highlights
- New `frames_per_buffer` parameter for audio buffering
- New `playout_chunk_size` parameter
- Stuttering fix for Unix systems
- Backward compatibility maintained
New Features
- Configurable playback parameters (`frames_per_buffer`, `playout_chunk_size`)
Full Release Notes
# 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:
```python
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:
```python
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**:
```python
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.