Class: AssemblyAI::Transcripts::SentencesResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/assemblyai/transcripts/types/sentences_response.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, confidence:, audio_duration:, sentences:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::SentencesResponse

Parameters:

  • id (String)

    The unique identifier for the transcript

  • confidence (Float)

    The confidence score for the transcript

  • audio_duration (Float)

    The duration of the audio file in seconds

  • sentences (Array<AssemblyAI::Transcripts::TranscriptSentence>)

    An array of sentences in the transcript

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



32
33
34
35
36
37
38
39
# File 'lib/assemblyai/transcripts/types/sentences_response.rb', line 32

def initialize(id:, confidence:, audio_duration:, sentences:, additional_properties: nil)
  @id = id
  @confidence = confidence
  @audio_duration = audio_duration
  @sentences = sentences
  @additional_properties = additional_properties
  @_field_set = { "id": id, "confidence": confidence, "audio_duration": audio_duration, "sentences": sentences }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



19
20
21
# File 'lib/assemblyai/transcripts/types/sentences_response.rb', line 19

def additional_properties
  @additional_properties
end

#audio_durationFloat (readonly)

Returns The duration of the audio file in seconds.

Returns:

  • (Float)

    The duration of the audio file in seconds



15
16
17
# File 'lib/assemblyai/transcripts/types/sentences_response.rb', line 15

def audio_duration
  @audio_duration
end

#confidenceFloat (readonly)

Returns The confidence score for the transcript.

Returns:

  • (Float)

    The confidence score for the transcript



13
14
15
# File 'lib/assemblyai/transcripts/types/sentences_response.rb', line 13

def confidence
  @confidence
end

#idString (readonly)

Returns The unique identifier for the transcript.

Returns:

  • (String)

    The unique identifier for the transcript



11
12
13
# File 'lib/assemblyai/transcripts/types/sentences_response.rb', line 11

def id
  @id
end

#sentencesArray<AssemblyAI::Transcripts::TranscriptSentence> (readonly)

Returns An array of sentences in the transcript.

Returns:



17
18
19
# File 'lib/assemblyai/transcripts/types/sentences_response.rb', line 17

def sentences
  @sentences
end

Class Method Details

.from_json(json_object:) ⇒ AssemblyAI::Transcripts::SentencesResponse

Deserialize a JSON object to an instance of SentencesResponse

Parameters:

  • json_object (String)

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/assemblyai/transcripts/types/sentences_response.rb', line 45

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = struct["id"]
  confidence = struct["confidence"]
  audio_duration = struct["audio_duration"]
  sentences = parsed_json["sentences"]&.map do |v|
    v = v.to_json
    AssemblyAI::Transcripts::TranscriptSentence.from_json(json_object: v)
  end
  new(
    id: id,
    confidence: confidence,
    audio_duration: audio_duration,
    sentences: sentences,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


77
78
79
80
81
82
# File 'lib/assemblyai/transcripts/types/sentences_response.rb', line 77

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
  obj.audio_duration.is_a?(Float) != false || raise("Passed value for field obj.audio_duration is not the expected type, validation failed.")
  obj.sentences.is_a?(Array) != false || raise("Passed value for field obj.sentences is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of SentencesResponse to a JSON object

Returns:

  • (String)


67
68
69
# File 'lib/assemblyai/transcripts/types/sentences_response.rb', line 67

def to_json(*_args)
  @_field_set&.to_json
end