class AzureSTT::Models::Transcription
Model for a transcription. Contains the results and static methods to create and retrieve the transcriptions.
Public Instance Methods
Is the status is failed ?
@return [Boolean]
# File lib/azure_stt/models/transcription.rb, line 101 def failed? status == 'Failed' end
Is the process finished ? (Succeeded or failed)
@return [Boolean]
# File lib/azure_stt/models/transcription.rb, line 119 def finished? succeeded? || failed? end
Get the report of a transcription from transcriptions/id/files route
@return [Models::Report]
# File lib/azure_stt/models/transcription.rb, line 130 def report @report ||= retrieve_report end
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
Is the process still running ?
@return [Boolean]
# File lib/azure_stt/models/transcription.rb, line 92 def running? status == 'Running' end
Has the process succeeded ?
@return [Boolean]
# File lib/azure_stt/models/transcription.rb, line 110 def succeeded? status == 'Succeeded' end
Private Instance Methods
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
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
# 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
# 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