Class: AssemblyAI::Transcripts::TranscriptParagraph
- Inherits:
-
Object
- Object
- AssemblyAI::Transcripts::TranscriptParagraph
- Defined in:
- lib/assemblyai/transcripts/types/transcript_paragraph.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#confidence ⇒ Float
readonly
The confidence score for the transcript of this paragraph.
-
#end_ ⇒ Integer
readonly
The ending time, in milliseconds, of the paragraph.
-
#start ⇒ Integer
readonly
The starting time, in milliseconds, of the paragraph.
-
#text ⇒ String
readonly
The transcript of the paragraph.
-
#words ⇒ Array<AssemblyAI::Transcripts::TranscriptWord>
readonly
An array of words in the paragraph.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::TranscriptParagraph
Deserialize a JSON object to an instance of TranscriptParagraph.
-
.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.
Instance Method Summary collapse
- #initialize(text:, start:, end_:, confidence:, words:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::TranscriptParagraph constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of TranscriptParagraph to a JSON object.
Constructor Details
#initialize(text:, start:, end_:, confidence:, words:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::TranscriptParagraph
35 36 37 38 39 40 41 42 43 |
# File 'lib/assemblyai/transcripts/types/transcript_paragraph.rb', line 35 def initialize(text:, start:, end_:, confidence:, words:, additional_properties: nil) @text = text @start = start @end_ = end_ @confidence = confidence @words = words @additional_properties = additional_properties @_field_set = { "text": text, "start": start, "end": end_, "confidence": confidence, "words": words } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
21 22 23 |
# File 'lib/assemblyai/transcripts/types/transcript_paragraph.rb', line 21 def additional_properties @additional_properties end |
#confidence ⇒ Float (readonly)
Returns The confidence score for the transcript of this paragraph.
17 18 19 |
# File 'lib/assemblyai/transcripts/types/transcript_paragraph.rb', line 17 def confidence @confidence end |
#end_ ⇒ Integer (readonly)
Returns The ending time, in milliseconds, of the paragraph.
15 16 17 |
# File 'lib/assemblyai/transcripts/types/transcript_paragraph.rb', line 15 def end_ @end_ end |
#start ⇒ Integer (readonly)
Returns The starting time, in milliseconds, of the paragraph.
13 14 15 |
# File 'lib/assemblyai/transcripts/types/transcript_paragraph.rb', line 13 def start @start end |
#text ⇒ String (readonly)
Returns The transcript of the paragraph.
11 12 13 |
# File 'lib/assemblyai/transcripts/types/transcript_paragraph.rb', line 11 def text @text end |
#words ⇒ Array<AssemblyAI::Transcripts::TranscriptWord> (readonly)
Returns An array of words in the paragraph.
19 20 21 |
# File 'lib/assemblyai/transcripts/types/transcript_paragraph.rb', line 19 def words @words end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::TranscriptParagraph
Deserialize a JSON object to an instance of TranscriptParagraph
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/assemblyai/transcripts/types/transcript_paragraph.rb', line 49 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) text = struct["text"] start = struct["start"] end_ = struct["end"] confidence = struct["confidence"] words = parsed_json["words"]&.map do |v| v = v.to_json AssemblyAI::Transcripts::TranscriptWord.from_json(json_object: v) end new( text: text, start: start, end_: end_, confidence: confidence, words: words, 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.
83 84 85 86 87 88 89 |
# File 'lib/assemblyai/transcripts/types/transcript_paragraph.rb', line 83 def self.validate_raw(obj:) obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") obj.start.is_a?(Integer) != false || raise("Passed value for field obj.start is not the expected type, validation failed.") obj.end_.is_a?(Integer) != false || raise("Passed value for field obj.end_ 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.words.is_a?(Array) != false || raise("Passed value for field obj.words is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of TranscriptParagraph to a JSON object
73 74 75 |
# File 'lib/assemblyai/transcripts/types/transcript_paragraph.rb', line 73 def to_json(*_args) @_field_set&.to_json end |