Module: AIA::Adapter::ModalityHandlers

Included in:
RubyLLMAdapter
Defined in:
lib/aia/adapter/modality_handlers.rb

Instance Method Summary collapse

Instance Method Details

#speak(_text) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/aia/adapter/modality_handlers.rb', line 15

def speak(_text)
  # NOTE: RubyLLM doesn't have a direct text-to-speech feature
  # This is a placeholder for a custom implementation or external service
  tmpfile = Tempfile.new(['aia-tts-', '.mp3'])
  begin
    tmpfile.write('Mock TTS audio content')
    tmpfile.close
    speak_cmd = AIA.config.audio.speak_command
    if system('which', speak_cmd, out: File::NULL, err: File::NULL)
      system(speak_cmd, tmpfile.path)
    end
    "Audio generated successfully"
  rescue StandardError => e
    "Error generating audio: #{e.message}"
  ensure
    tmpfile.unlink
  end
end

#transcribe(audio_file) ⇒ Object



9
10
11
12
13
# File 'lib/aia/adapter/modality_handlers.rb', line 9

def transcribe(audio_file)
  # Use the first model for transcription
  first_model = @models.first
  @chats[first_model].ask('Transcribe this audio', with: audio_file).content
end