Module: RubyLLM::Agents::Speaker::ActiveStorageSupport

Extended by:
ActiveSupport::Concern
Defined in:
lib/ruby_llm/agents/audio/speaker/active_storage_support.rb

Overview

ActiveStorage integration for speakers

Provides convenience methods for generating audio and directly attaching it to ActiveStorage attachments.

Examples:

Attaching to a model

class Article < ApplicationRecord
  has_one_attached :narration
end

class ArticleNarrator < RubyLLM::Agents::Speaker
  include RubyLLM::Agents::Speaker::ActiveStorageSupport

  provider :openai
  model 'tts-1-hd'
  voice 'nova'
end

article = Article.find(1)
result = ArticleNarrator.speak_and_attach(
  text: article.body,
  record: article,
  attachment_name: :narration
)