Module: Cohere::Transcribe
- Defined in:
- lib/cohere/transcribe.rb,
lib/cohere/transcribe/api.rb,
lib/cohere/transcribe/cli.rb,
lib/cohere/transcribe/hub.rb,
lib/cohere/transcribe/input.rb,
lib/cohere/transcribe/types.rb,
lib/cohere/transcribe/doctor.rb,
lib/cohere/transcribe/errors.rb,
lib/cohere/transcribe/loader.rb,
lib/cohere/transcribe/version.rb,
lib/cohere/transcribe/state/io.rb,
lib/cohere/transcribe/constants.rb,
lib/cohere/transcribe/asr/native.rb,
lib/cohere/transcribe/vad/silero.rb,
lib/cohere/transcribe/gguf_writer.rb,
lib/cohere/transcribe/python_text.rb,
lib/cohere/transcribe/safetensors.rb,
lib/cohere/transcribe/asr/batching.rb,
lib/cohere/transcribe/alignment/ctc.rb,
lib/cohere/transcribe/audio/decoder.rb,
lib/cohere/transcribe/configuration.rb,
lib/cohere/transcribe/output/timing.rb,
lib/cohere/transcribe/state/locking.rb,
lib/cohere/transcribe/alignment/text.rb,
lib/cohere/transcribe/model_identity.rb,
lib/cohere/transcribe/runtime/engine.rb,
lib/cohere/transcribe/state/manifest.rb,
lib/cohere/transcribe/vad/timestamps.rb,
lib/cohere/transcribe/dense_converter.rb,
lib/cohere/transcribe/state/contracts.rb,
lib/cohere/transcribe/output/rendering.rb,
lib/cohere/transcribe/state/checkpoint.rb,
lib/cohere/transcribe/alignment/aligner.rb,
lib/cohere/transcribe/runtime/precision.rb,
lib/cohere/transcribe/runtime/resources.rb,
lib/cohere/transcribe/asr/failure_policy.rb,
lib/cohere/transcribe/audio/segmentation.rb,
lib/cohere/transcribe/output/publication.rb,
lib/cohere/transcribe/pytorch_checkpoint.rb,
lib/cohere/transcribe/audio/ffmpeg_native.rb,
lib/cohere/transcribe/runtime/preparation.rb,
lib/cohere/transcribe/alignment/uroman_data.rb,
lib/cohere/transcribe/runtime/word_pipeline.rb,
lib/cohere/transcribe/runtime/model_provider.rb,
sig/cohere/transcribe.rbs
Defined Under Namespace
Modules: ASR, Alignment, Audio, CLI, Configuration, Doctor, GGUF, Input, ModelIdentity, Output, PyTorchCheckpoint, Runtime, Safetensors, State, VAD, _ToPath Classes: BatchTranscriptionError, DenseConverter, Error, Hub, InputEntry, ProgressCallbackError, ProgressEvent, PublicationOptions, ResolvedModelIdentity, SubtitleCue, Transcriber, TranscriberBusyError, TranscriberClosedError, TranscriptionConfigurationError, TranscriptionError, TranscriptionInputError, TranscriptionOptions, TranscriptionProvenance, TranscriptionResult, TranscriptionRun, TranscriptionRuntimeError, TranscriptionSegment, TranscriptionStatistics, TranscriptionWord
Constant Summary collapse
- PUBLIC_API =
Ruby counterpart to the Python package's explicit root export contract. Internal implementation constants remain reachable through autoloads but are intentionally absent from this stable list.
%w[ BatchTranscriptionError Error ProgressCallbackError ProgressEvent PublicationOptions SubtitleCue Transcriber TranscriberBusyError TranscriberClosedError TranscriptionConfigurationError TranscriptionError TranscriptionInputError TranscriptionOptions TranscriptionProvenance TranscriptionResult TranscriptionRun TranscriptionRuntimeError TranscriptionSegment TranscriptionStatistics TranscriptionWord VERSION transcribe ].freeze
- VERSION =
"0.1.1"- DEFAULT_ASR_MODEL_ID =
"CohereLabs/cohere-transcribe-arabic-07-2026"- DEFAULT_ASR_MODEL_REVISION =
"0a8193caa4f3f92131471ab08824e488141cb392"- SAMPLE_RATE =
16_000- AUDIO_EXTENSIONS =
%w[ .aac .aif .aiff .alac .flac .m4a .mp3 .mp4 .oga .ogg .opus .wav .wave .webm .wma ].freeze
- OUTPUT_FORMATS =
%i[txt srt vtt json].freeze
Class Method Summary collapse
Class Method Details
.transcribe(audio, options: nil, progress: nil, raise_on_error: false) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/cohere/transcribe/api.rb', line 147 def transcribe(audio, options: nil, progress: nil, raise_on_error: false) started = Process.clock_gettime(Process::CLOCK_MONOTONIC) transcriber = Transcriber.new(, progress: progress) run = nil batch_error = nil begin begin run = transcriber.transcribe(audio, raise_on_error: raise_on_error) rescue BatchTranscriptionError => e batch_error = e end ensure transcriber.close end elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started selected = batch_error ? batch_error.run : run statistics = selected.statistics.with( elapsed_seconds: elapsed, real_time_factor_x: elapsed.positive? ? selected.statistics.successful_audio_seconds / elapsed : 0.0 ) selected = selected.with(statistics: statistics) raise BatchTranscriptionError.new(selected) if batch_error selected end |