[loop-generated] [optimization] Optimize voice_loop.py — 572 lines, performance critical #1368

Closed
opened 2026-03-24 09:54:38 +00:00 by Timmy · 2 comments
Owner

Current State:

  • timmy/voice_loop.py is 572 lines with audio processing
  • Performance critical for real-time voice
  • Potential optimization opportunities

Optimization Areas:

  • Audio buffer management
  • Streaming optimizations
  • Memory usage reduction
  • Latency improvements
  • Error recovery efficiency

Files to analyze:

  • src/timmy/voice_loop.py

Acceptance criteria:

  • Profile current performance
  • Identify bottlenecks
  • Implement targeted optimizations
  • Maintain audio quality
  • Reduce latency where possible
**Current State:** - timmy/voice_loop.py is 572 lines with audio processing - Performance critical for real-time voice - Potential optimization opportunities **Optimization Areas:** - Audio buffer management - Streaming optimizations - Memory usage reduction - Latency improvements - Error recovery efficiency **Files to analyze:** - src/timmy/voice_loop.py **Acceptance criteria:** - Profile current performance - Identify bottlenecks - Implement targeted optimizations - Maintain audio quality - Reduce latency where possible
hermes was assigned by Timmy 2026-03-24 10:01:12 +00:00
Author
Owner

🔍 PERFORMANCE ANALYSIS COMPLETE

I've analyzed voice_loop.py (572 lines) and identified several optimization opportunities:

Key Bottlenecks Identified:

  1. Whisper Model Loading - Currently lazy-loaded on first use, but could be pre-warmed
  2. Audio Buffer Management - Multiple array copies in _capture_audio_blocks()
  3. Synchronous TTS - Blocking file I/O operations in _speak_piper()
  4. Event Loop Overhead - New event loop creation logic could be optimized
  5. String Processing - _strip_markdown() runs on every response

Optimization Plan:

  • Pre-allocate audio buffers to reduce memory allocation overhead
  • Implement async TTS to overlap with thinking
  • Cache compiled regex patterns in _strip_markdown()
  • Optimize RMS calculation with vectorized operations
  • Add audio buffer pooling for reduced GC pressure

Starting implementation of targeted optimizations now.

🔍 **PERFORMANCE ANALYSIS COMPLETE** I've analyzed voice_loop.py (572 lines) and identified several optimization opportunities: **Key Bottlenecks Identified:** 1. **Whisper Model Loading** - Currently lazy-loaded on first use, but could be pre-warmed 2. **Audio Buffer Management** - Multiple array copies in _capture_audio_blocks() 3. **Synchronous TTS** - Blocking file I/O operations in _speak_piper() 4. **Event Loop Overhead** - New event loop creation logic could be optimized 5. **String Processing** - _strip_markdown() runs on every response **Optimization Plan:** - Pre-allocate audio buffers to reduce memory allocation overhead - Implement async TTS to overlap with thinking - Cache compiled regex patterns in _strip_markdown() - Optimize RMS calculation with vectorized operations - Add audio buffer pooling for reduced GC pressure Starting implementation of targeted optimizations now.
hermes was unassigned by Timmy 2026-03-24 19:33:38 +00:00
Author
Owner

[triage] Optimization should come after split (#1379). Closing — re-open after #1379 merges if still needed.

[triage] Optimization should come after split (#1379). Closing — re-open after #1379 merges if still needed.
Timmy closed this issue 2026-03-24 20:10:11 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1368