Class: AssemblyAI::Transcripts::AutoHighlightResult

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(count:, rank:, text:, timestamps:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::AutoHighlightResult

Parameters:

  • count (Integer)

    The total number of times the key phrase appears in the audio file

  • rank (Float)

    The total relevancy to the overall audio file of this key phrase - a greater number means more relevant

  • text (String)

    The text itself of the key phrase

  • timestamps (Array<AssemblyAI::Transcripts::Timestamp>)

    The timestamp of the of the key phrase

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



34
35
36
37
38
39
40
41
# File 'lib/assemblyai/transcripts/types/auto_highlight_result.rb', line 34

def initialize(count:, rank:, text:, timestamps:, additional_properties: nil)
  @count = count
  @rank = rank
  @text = text
  @timestamps = timestamps
  @additional_properties = additional_properties
  @_field_set = { "count": count, "rank": rank, "text": text, "timestamps": timestamps }
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



20
21
22
# File 'lib/assemblyai/transcripts/types/auto_highlight_result.rb', line 20

def additional_properties
  @additional_properties
end

#countInteger (readonly)

Returns The total number of times the key phrase appears in the audio file.

Returns:

  • (Integer)

    The total number of times the key phrase appears in the audio file



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

def count
  @count
end

#rankFloat (readonly)

Returns The total relevancy to the overall audio file of this key phrase - a greater number means more relevant.

Returns:

  • (Float)

    The total relevancy to the overall audio file of this key phrase - a greater number means more relevant



14
15
16
# File 'lib/assemblyai/transcripts/types/auto_highlight_result.rb', line 14

def rank
  @rank
end

#textString (readonly)

Returns The text itself of the key phrase.

Returns:

  • (String)

    The text itself of the key phrase



16
17
18
# File 'lib/assemblyai/transcripts/types/auto_highlight_result.rb', line 16

def text
  @text
end

#timestampsArray<AssemblyAI::Transcripts::Timestamp> (readonly)

Returns The timestamp of the of the key phrase.

Returns:



18
19
20
# File 'lib/assemblyai/transcripts/types/auto_highlight_result.rb', line 18

def timestamps
  @timestamps
end

Class Method Details

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

Deserialize a JSON object to an instance of AutoHighlightResult

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  count = struct["count"]
  rank = struct["rank"]
  text = struct["text"]
  timestamps = parsed_json["timestamps"]&.map do |v|
    v = v.to_json
    AssemblyAI::Transcripts::Timestamp.from_json(json_object: v)
  end
  new(
    count: count,
    rank: rank,
    text: text,
    timestamps: timestamps,
    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)


79
80
81
82
83
84
# File 'lib/assemblyai/transcripts/types/auto_highlight_result.rb', line 79

def self.validate_raw(obj:)
  obj.count.is_a?(Integer) != false || raise("Passed value for field obj.count is not the expected type, validation failed.")
  obj.rank.is_a?(Float) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
  obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
  obj.timestamps.is_a?(Array) != false || raise("Passed value for field obj.timestamps is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AutoHighlightResult to a JSON object

Returns:

  • (String)


69
70
71
# File 'lib/assemblyai/transcripts/types/auto_highlight_result.rb', line 69

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