Class: TTSEngineFactory

Inherits:
Object show all
Defined in:
lib/parse_animation_to_tts.rb

Overview

TTS Engine Factory REQUIREMENTS: Create TTS engine factory for backend selection SEMANTIC TOKENS: TTS_ENGINE_FACTORY, BACKEND_SELECTION ARCHITECTURE: TTS engine factory with backend selection IMPLEMENTATION: Factory pattern for TTS engine creation TEST: Test TTS engine factory and backend selection

Class Method Summary collapse

Class Method Details

.available_backendsObject

REQUIREMENTS: Get list of available TTS backends SEMANTIC TOKENS: BACKEND_LISTING, AVAILABILITY_CHECK ARCHITECTURE: TTS backend listing architecture IMPLEMENTATION: Scan system for available TTS backends TEST: Test TTS backend listing



1547
1548
1549
1550
1551
1552
1553
# File 'lib/parse_animation_to_tts.rb', line 1547

def self.available_backends
  backends = []
  backends << 'espeak' if system('which espeak > /dev/null 2>&1')
  backends << 'say' if system('which say > /dev/null 2>&1')
  backends << 'festival' if system('which festival > /dev/null 2>&1')
  backends
end

.create(backend = 'auto', config = {}) ⇒ Object

REQUIREMENTS: Create TTS engine instance SEMANTIC TOKENS: TTS_ENGINE_CREATE, FACTORY_PATTERN ARCHITECTURE: TTS engine factory architecture IMPLEMENTATION: Create TTS engine with specified backend TEST: Test TTS engine creation with different backends



1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
# File 'lib/parse_animation_to_tts.rb', line 1521

def self.create(backend = 'auto', config = {})
  case backend
  when 'auto'
    # REQUIREMENTS: Auto-detect best available TTS backend
    # SEMANTIC TOKENS: AUTO_DETECTION, BACKEND_SELECTION
    # ARCHITECTURE: Automatic backend selection
    # IMPLEMENTATION: Select best available TTS backend
    # TEST: Test automatic backend selection
    SystemTTSEngine.new(config)
  when 'espeak', 'say', 'festival'
    # REQUIREMENTS: Create specific TTS backend
    # SEMANTIC TOKENS: SPECIFIC_BACKEND, BACKEND_CREATE
    # ARCHITECTURE: Specific backend creation
    # IMPLEMENTATION: Create TTS engine with specific backend
    # TEST: Test specific backend creation
    SystemTTSEngine.new(config.merge(backend: backend))
  else
    raise "Unsupported TTS backend: #{backend}"
  end
end