class AzureSTT::Models::Transcription

Model for a transcription. Contains the results and static methods to create and retrieve the transcriptions.

Public Instance Methods

failed?() click to toggle source

Is the status is failed ?

@return [Boolean]

# File lib/azure_stt/models/transcription.rb, line 101
def failed?
  status == 'Failed'
end
finished?() click to toggle source

Is the process finished ? (Succeeded or failed)

@return [Boolean]

# File lib/azure_stt/models/transcription.rb, line 119
def finished?
  succeeded? || failed?
end
report() click to toggle source

Get the report of a transcription from transcriptions/id/files route

@see centralus.dev.cognitive.microsoft.com/docs/services/speech-to-text-api-v3-0/operations/GetTranscriptionFiles/console

@return [Models::Report]

# File lib/azure_stt/models/transcription.rb, line 130
def report
  @report ||= retrieve_report
end
results() click to toggle source

Get the results of a transcription. The results are the files containing the speech-to-text. As a transcription process can have multiple files, the results are in an Array.

@return [Array]

# File lib/azure_stt/models/transcription.rb, line 141
def results
  @results ||= retrieve_results
end
running?() click to toggle source

Is the process still running ?

@return [Boolean]

# File lib/azure_stt/models/transcription.rb, line 92
def running?
  status == 'Running'
end
succeeded?() click to toggle source

Has the process succeeded ?

@return [Boolean]

# File lib/azure_stt/models/transcription.rb, line 110
def succeeded?
  status == 'Succeeded'
end

Private Instance Methods

files() click to toggle source

All the files of a transcription

@return [Array] The files of the transcription

# File lib/azure_stt/models/transcription.rb, line 152
def files
  @files ||= retrieve_files
end
retrieve_files() click to toggle source

Interrogate the API to retrieve the files

@return [Array] The files of the transcription

# File lib/azure_stt/models/transcription.rb, line 161
def retrieve_files
  files_array = client.get_transcription_files(id)
  files_array.map do |file_hash|
    Models::File.new(
      Parsers::File.new(file_hash).attributes.merge({ client: client })
    )
  end
end
retrieve_report() click to toggle source
# File lib/azure_stt/models/transcription.rb, line 170
def retrieve_report
  report_file = files.find { |f| f.kind == 'TranscriptionReport' }
  file_hash = report_file.content
  Models::Report.new(Parsers::Report.new(file_hash).attributes)
end
retrieve_results() click to toggle source
# File lib/azure_stt/models/transcription.rb, line 176
def retrieve_results
  results_files = files.select { |f| f.kind == 'Transcription' }
  results_files.map do |result_file|
    result_hash = result_file.content
    Models::Result.new(Parsers::Result.new(result_hash).attributes)
  end
end