Class: AssemblyAI::Transcripts::ContentSafetyLabelsResult

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

Overview

An array of results for the Content Moderation model, if it is enabled.

See [Content
moderation](https://www.assemblyai.com/docs/models/content-moderation) 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:, severity_score_summary:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::ContentSafetyLabelsResult

Parameters:



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/assemblyai/transcripts/types/content_safety_labels_result.rb', line 39

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



25
26
27
# File 'lib/assemblyai/transcripts/types/content_safety_labels_result.rb', line 25

def additional_properties
  @additional_properties
end

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

Returns An array of results for the Content Moderation model.

Returns:



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

def results
  @results
end

#severity_score_summaryHash{String => AssemblyAI::Transcripts::SeverityScoreSummary} (readonly)

Returns A summary of the Content Moderation severity results for the entire audio file.

Returns:



23
24
25
# File 'lib/assemblyai/transcripts/types/content_safety_labels_result.rb', line 23

def severity_score_summary
  @severity_score_summary
end

#statusAssemblyAI::Transcripts::AudioIntelligenceModelStatus (readonly)

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

Returns:



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

def status
  @status
end

#summaryHash{String => Float} (readonly)

Returns A summary of the Content Moderation confidence results for the entire audio file.

Returns:

  • (Hash{String => Float})

    A summary of the Content Moderation confidence results for the entire audio file



21
22
23
# File 'lib/assemblyai/transcripts/types/content_safety_labels_result.rb', line 21

def summary
  @summary
end

Class Method Details

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

Deserialize a JSON object to an instance of ContentSafetyLabelsResult

Parameters:

  • json_object (String)

Returns:



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/assemblyai/transcripts/types/content_safety_labels_result.rb', line 57

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::ContentSafetyLabelResult.from_json(json_object: v)
  end
  summary = struct["summary"]
  severity_score_summary = parsed_json["severity_score_summary"]&.transform_values do |v|
    v = v.to_json
    AssemblyAI::Transcripts::SeverityScoreSummary.from_json(json_object: v)
  end
  new(
    status: status,
    results: results,
    summary: summary,
    severity_score_summary: severity_score_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)


92
93
94
95
96
97
# File 'lib/assemblyai/transcripts/types/content_safety_labels_result.rb', line 92

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.")
  obj.severity_score_summary.is_a?(Hash) != false || raise("Passed value for field obj.severity_score_summary is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ContentSafetyLabelsResult to a JSON object

Returns:

  • (String)


82
83
84
# File 'lib/assemblyai/transcripts/types/content_safety_labels_result.rb', line 82

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