Class: Cohere::Transcribe::TranscriptionRun

Inherits:
Data
  • Object
show all
Includes:
Enumerable, Enumerable[TranscriptionResult]
Defined in:
lib/cohere/transcribe/types.rb,
sig/cohere/transcribe.rbs

Overview

Immutable, sequence-like result of one API call.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results:, requested_options:, resolved_options:, statistics:, errors: []) ⇒ TranscriptionRun

Returns a new instance of TranscriptionRun.



455
456
457
458
459
460
461
462
463
# File 'lib/cohere/transcribe/types.rb', line 455

def initialize(results:, requested_options:, resolved_options:, statistics:, errors: [])
  super(
    results: TypesSupport.tuple(results, field: "results"),
    requested_options: requested_options,
    resolved_options: resolved_options,
    statistics: statistics,
    errors: TypesSupport.tuple(errors, field: "errors")
  )
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors

Returns:

  • (Object)

    the current value of errors



446
447
448
# File 'lib/cohere/transcribe/types.rb', line 446

def errors
  @errors
end

#requested_optionsObject (readonly)

Returns the value of attribute requested_options

Returns:

  • (Object)

    the current value of requested_options



446
447
448
# File 'lib/cohere/transcribe/types.rb', line 446

def requested_options
  @requested_options
end

#resolved_optionsObject (readonly)

Returns the value of attribute resolved_options

Returns:

  • (Object)

    the current value of resolved_options



446
447
448
# File 'lib/cohere/transcribe/types.rb', line 446

def resolved_options
  @resolved_options
end

#resultsObject (readonly)

Returns the value of attribute results

Returns:

  • (Object)

    the current value of results



446
447
448
# File 'lib/cohere/transcribe/types.rb', line 446

def results
  @results
end

#statisticsObject (readonly)

Returns the value of attribute statistics

Returns:

  • (Object)

    the current value of statistics



446
447
448
# File 'lib/cohere/transcribe/types.rb', line 446

def statistics
  @statistics
end

Instance Method Details

#[](arg0) ⇒ TranscriptionResult #[](arg0) ⇒ Array[TranscriptionResult] #[](arg0, arg1) ⇒ Array[TranscriptionResult]

Overloads:



488
489
490
491
# File 'lib/cohere/transcribe/types.rb', line 488

def [](*)
  selected = results[*]
  selected.is_a?(Array) ? selected.freeze : selected
end

#eachself #eachEnumerator[TranscriptionResult, self]

Overloads:

Yields:

Yield Parameters:

Yield Returns:

  • (void)


465
466
467
468
469
# File 'lib/cohere/transcribe/types.rb', line 465

def each(&block)
  return results.each unless block

  results.each(&block)
end

#failedArray[TranscriptionResult]

Returns:



506
507
508
# File 'lib/cohere/transcribe/types.rb', line 506

def failed
  results.select { |result| result.status == "failed" }.freeze
end

#lengthInteger Also known as: size

Returns:

  • (Integer)


483
484
485
# File 'lib/cohere/transcribe/types.rb', line 483

def length
  results.length
end

#ok?Boolean Also known as: ok

Returns:

  • (Boolean)


514
515
516
# File 'lib/cohere/transcribe/types.rb', line 514

def ok?
  failed.empty? && errors.empty?
end

#singleTranscriptionResult

Returns:



493
494
495
496
497
498
499
500
# File 'lib/cohere/transcribe/types.rb', line 493

def single
  unless results.length == 1
    raise ArgumentError,
          "Expected exactly one expanded audio file, found #{results.length}"
  end

  results.first
end

#skippedArray[TranscriptionResult]

Returns:



510
511
512
# File 'lib/cohere/transcribe/types.rb', line 510

def skipped
  results.select { |result| result.status == "skipped" }.freeze
end

#successfulArray[TranscriptionResult]

Returns:



502
503
504
# File 'lib/cohere/transcribe/types.rb', line 502

def successful
  results.select { |result| result.status == "completed" }.freeze
end

#to_hObject

Enumerable#to_h otherwise shadows Data#to_h and interprets results as key-value pairs instead of returning this value object's fields.



473
474
475
476
477
478
479
480
481
# File 'lib/cohere/transcribe/types.rb', line 473

def to_h
  {
    results: results,
    requested_options: requested_options,
    resolved_options: resolved_options,
    statistics: statistics,
    errors: errors
  }
end