Class: OmniAI::Google::Transcribe

Inherits:
Transcribe
  • Object
show all
Includes:
TranscribeHelpers
Defined in:
lib/omniai/google/transcribe.rb,
lib/omniai/google/transcribe/gemini.rb

Overview

A Google transcribe implementation.

Usage:

transcribe = OmniAI::Google::Transcribe.new(client: client)
transcribe.process!(audio_file)

Defined Under Namespace

Modules: Model Classes: Gemini

Constant Summary collapse

DEFAULT_MODEL =
Model::LATEST_SHORT
DEFAULT_RECOGNIZER =
"_"
CONTEXT =

Returns:

  • (Context)
Context.build do |context|
  # No custom deserializers needed - let base class handle parsing
end
GEMINI_OPTIONS =
%i[diarization word_timestamps vocabulary].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, client:, model:) ⇒ Transcribe

client is swapped for client.for_model(model), so locations routes the request.



53
54
55
# File 'lib/omniai/google/transcribe.rb', line 53

def initialize(io, client:, model:, **)
  super(io, client: client.for_model(model), model:, **)
end

Class Method Details

.process!(io, model:, **options) ⇒ OmniAI::Transcribe::Transcription

Gemini transcribe models (gemini-*) take a separate path; every Chirp / Speech-to-Text model is unchanged.

Returns:

  • (OmniAI::Transcribe::Transcription)


41
42
43
44
45
46
47
48
49
50
# File 'lib/omniai/google/transcribe.rb', line 41

def self.process!(io, model:, **options)
  return Gemini.process!(io, model:, **options) if Gemini.model?(model)

  unsupported = options.keys & GEMINI_OPTIONS
  if unsupported.any?
    raise ArgumentError, "#{unsupported.join(', ')} only supported by Gemini transcribe models, not #{model}"
  end

  super
end

Instance Method Details

#process! ⇒ OmniAI::Transcribe::Transcription

Returns:

  • (OmniAI::Transcribe::Transcription)

Raises:

  • (HTTPError)


60
61
62
63
64
65
66
# File 'lib/omniai/google/transcribe.rb', line 60

def process!
  if needs_async_recognition?
    process_async!
  else
    process_sync!
  end
end