Class: AssemblyAI::Transcripts::TopicDetectionModelResult

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

Overview

The result of the Topic Detection model, if it is enabled.

See [Topic Detection](https://www.assemblyai.com/docs/models/topic-detection)
for more information.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, results:, summary:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::TopicDetectionModelResult

Parameters:

  • status (AssemblyAI::Transcripts::AudioIntelligenceModelStatus)

    The status of the Topic Detection model. Either success, or unavailable in the rare case that the model failed.

  • results (Array<AssemblyAI::Transcripts::TopicDetectionResult>)

    An array of results for the Topic Detection model

  • summary (Hash{String => Float})

    The overall relevance of topic to the entire audio file

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(status:, results:, summary:, additional_properties: nil)
  @status = status
  @results = results
  @summary = summary
  @additional_properties = additional_properties
  @_field_set = { "status": status, "results": results, "summary": summary }
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



22
23
24
# File 'lib/assemblyai/transcripts/types/topic_detection_model_result.rb', line 22

def additional_properties
  @additional_properties
end

#resultsArray<AssemblyAI::Transcripts::TopicDetectionResult> (readonly)

Returns An array of results for the Topic Detection model.

Returns:



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

def results
  @results
end

#statusAssemblyAI::Transcripts::AudioIntelligenceModelStatus (readonly)

Returns The status of the Topic Detection model. Either success, or unavailable in the rare case that the model failed.

Returns:



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

def status
  @status
end

#summaryHash{String => Float} (readonly)

Returns The overall relevance of topic to the entire audio file.

Returns:

  • (Hash{String => Float})

    The overall relevance of topic to the entire audio file



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

def summary
  @summary
end

Class Method Details

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

Deserialize a JSON object to an instance of TopicDetectionModelResult

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  status = struct["status"]
  results = parsed_json["results"]&.map do |v|
    v = v.to_json
    AssemblyAI::Transcripts::TopicDetectionResult.from_json(json_object: v)
  end
  summary = struct["summary"]
  new(
    status: status,
    results: results,
    summary: summary,
    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
# File 'lib/assemblyai/transcripts/types/topic_detection_model_result.rb', line 77

def self.validate_raw(obj:)
  obj.status.is_a?(AssemblyAI::Transcripts::AudioIntelligenceModelStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.results.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.")
  obj.summary.is_a?(Hash) != false || raise("Passed value for field obj.summary is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of TopicDetectionModelResult to a JSON object

Returns:

  • (String)


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

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