Class: SystemTTSEngine
- Defined in:
- lib/parse_animation_to_tts.rb
Overview
System TTS Engine Implementation REQUIREMENTS: Implement system TTS backend (espeak, say, festival) SEMANTIC TOKENS: SYSTEM_TTS_BACKEND, SYSTEM_INTEGRATION ARCHITECTURE: System TTS backend with command-line integration IMPLEMENTATION: Use system TTS tools for audio generation TEST: Test system TTS backend functionality
Instance Method Summary collapse
-
#available? ⇒ Boolean
REQUIREMENTS: Check if system TTS backend is available SEMANTIC TOKENS: SYSTEM_TTS_AVAIL, BACKEND_CHECK ARCHITECTURE: System TTS availability checking IMPLEMENTATION: Check if TTS backend is installed and working TEST: Test system TTS backend availability.
-
#generate_audio(text, voice_settings = {}) ⇒ Object
REQUIREMENTS: Generate audio using system TTS tools SEMANTIC TOKENS: SYSTEM_AUDIO_GEN, COMMAND_EXECUTION ARCHITECTURE: System command execution for audio generation IMPLEMENTATION: Execute system TTS commands with voice settings TEST: Test system audio generation with voice settings.
-
#initialize(config = {}) ⇒ SystemTTSEngine
constructor
REQUIREMENTS: Initialize system TTS engine with backend selection SEMANTIC TOKENS: SYSTEM_TTS_INIT, BACKEND_SELECTION ARCHITECTURE: System TTS initialization architecture IMPLEMENTATION: Initialize with specific TTS backend TEST: Test system TTS engine initialization.
-
#supported_formats ⇒ Object
REQUIREMENTS: Get supported audio formats for system TTS SEMANTIC TOKENS: SYSTEM_AUDIO_FORMATS, FORMAT_SUPPORT ARCHITECTURE: System audio format support IMPLEMENTATION: Return formats supported by system TTS TEST: Test system audio format support.
Methods inherited from TTSEngine
Constructor Details
#initialize(config = {}) ⇒ SystemTTSEngine
REQUIREMENTS: Initialize system TTS engine with backend selection SEMANTIC TOKENS: SYSTEM_TTS_INIT, BACKEND_SELECTION ARCHITECTURE: System TTS initialization architecture IMPLEMENTATION: Initialize with specific TTS backend TEST: Test system TTS engine initialization
1317 1318 1319 1320 1321 |
# File 'lib/parse_animation_to_tts.rb', line 1317 def initialize(config = {}) super(config) @backend = config[:backend] || detect_available_backend @temp_dir = config[:temp_dir] || Dir.mktmpdir end |
Instance Method Details
#available? ⇒ Boolean
REQUIREMENTS: Check if system TTS backend is available SEMANTIC TOKENS: SYSTEM_TTS_AVAIL, BACKEND_CHECK ARCHITECTURE: System TTS availability checking IMPLEMENTATION: Check if TTS backend is installed and working TEST: Test system TTS backend availability
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 |
# File 'lib/parse_animation_to_tts.rb', line 1376 def available? case @backend when 'espeak' system('which espeak > /dev/null 2>&1') when 'say' system('which say > /dev/null 2>&1') when 'festival' system('which festival > /dev/null 2>&1') else false end end |
#generate_audio(text, voice_settings = {}) ⇒ Object
REQUIREMENTS: Generate audio using system TTS tools SEMANTIC TOKENS: SYSTEM_AUDIO_GEN, COMMAND_EXECUTION ARCHITECTURE: System command execution for audio generation IMPLEMENTATION: Execute system TTS commands with voice settings TEST: Test system audio generation with voice settings
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 |
# File 'lib/parse_animation_to_tts.rb', line 1328 def generate_audio(text, voice_settings = {}) # REQUIREMENTS: Apply voice settings to system TTS commands # SEMANTIC TOKENS: VOICE_SETTINGS_APP, COMMAND_PARAMETERS # ARCHITECTURE: Voice settings to command parameter mapping # IMPLEMENTATION: Convert voice settings to TTS command parameters # TEST: Test voice settings application to system commands settings = @voice_settings.merge(voice_settings) # REQUIREMENTS: Generate temporary audio file # SEMANTIC TOKENS: TEMP_FILE_GEN, AUDIO_OUTPUT # ARCHITECTURE: Temporary file management for audio generation # IMPLEMENTATION: Create temporary audio file with unique name # TEST: Test temporary audio file generation temp_file = File.join(@temp_dir, "tts_#{Time.now.to_i}_#{rand(1000)}.aiff") # REQUIREMENTS: Execute system TTS command with voice settings # SEMANTIC TOKENS: SYSTEM_COMMAND_EXECUTION, TTS_PROCESSING # ARCHITECTURE: System command execution architecture # IMPLEMENTATION: Execute TTS command with proper parameters # TEST: Test system command execution with voice settings case @backend when 'espeak' generate_with_espeak(text, temp_file, settings) when 'say' generate_with_say(text, temp_file, settings) when 'festival' generate_with_festival(text, temp_file, settings) else raise "Unsupported TTS backend: #{@backend}" end # REQUIREMENTS: Validate generated audio file # SEMANTIC TOKENS: AUDIO_FILE_VALID, QUALITY_CHECK # ARCHITECTURE: Audio file validation architecture # IMPLEMENTATION: Verify audio file was created successfully # TEST: Test audio file validation and quality checks unless File.exist?(temp_file) && File.size(temp_file) > 0 raise "Failed to generate audio file" end temp_file end |
#supported_formats ⇒ Object
REQUIREMENTS: Get supported audio formats for system TTS SEMANTIC TOKENS: SYSTEM_AUDIO_FORMATS, FORMAT_SUPPORT ARCHITECTURE: System audio format support IMPLEMENTATION: Return formats supported by system TTS TEST: Test system audio format support
1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 |
# File 'lib/parse_animation_to_tts.rb', line 1394 def supported_formats case @backend when 'espeak' ['wav', 'mp3'] when 'say' ['wav', 'aiff'] when 'festival' ['wav'] else ['wav'] end end |