Class: AssemblyAI::Transcripts::TranscriptUtterance
- Inherits:
-
Object
- Object
- AssemblyAI::Transcripts::TranscriptUtterance
- Defined in:
- lib/assemblyai/transcripts/types/transcript_utterance.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 utterance.
-
#end_ ⇒ Integer
readonly
The ending time, in milliseconds, of the utterance in the audio file.
-
#speaker ⇒ String
readonly
The speaker of this utterance, where each speaker is assigned a sequential capital letter - e.g.
-
#start ⇒ Integer
readonly
The starting time, in milliseconds, of the utterance in the audio file.
-
#text ⇒ String
readonly
The text for this utterance.
-
#words ⇒ Array<AssemblyAI::Transcripts::TranscriptWord>
readonly
The words in the utterance.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::TranscriptUtterance
Deserialize a JSON object to an instance of TranscriptUtterance.
-
.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(confidence:, start:, end_:, text:, words:, speaker:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::TranscriptUtterance constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of TranscriptUtterance to a JSON object.
Constructor Details
#initialize(confidence:, start:, end_:, text:, words:, speaker:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::TranscriptUtterance
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 40 def initialize(confidence:, start:, end_:, text:, words:, speaker:, additional_properties: nil) @confidence = confidence @start = start @end_ = end_ @text = text @words = words @speaker = speaker @additional_properties = additional_properties @_field_set = { "confidence": confidence, "start": start, "end": end_, "text": text, "words": words, "speaker": speaker } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
24 25 26 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 24 def additional_properties @additional_properties end |
#confidence ⇒ Float (readonly)
Returns The confidence score for the transcript of this utterance.
11 12 13 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 11 def confidence @confidence end |
#end_ ⇒ Integer (readonly)
Returns The ending time, in milliseconds, of the utterance in the audio file.
15 16 17 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 15 def end_ @end_ end |
#speaker ⇒ String (readonly)
Returns The speaker of this utterance, where each speaker is assigned a sequential capital letter - e.g. “A” for Speaker A, “B” for Speaker B, etc.
22 23 24 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 22 def speaker @speaker end |
#start ⇒ Integer (readonly)
Returns The starting time, in milliseconds, of the utterance in the audio file.
13 14 15 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 13 def start @start end |
#text ⇒ String (readonly)
Returns The text for this utterance.
17 18 19 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 17 def text @text end |
#words ⇒ Array<AssemblyAI::Transcripts::TranscriptWord> (readonly)
Returns The words in the utterance.
19 20 21 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 19 def words @words end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::TranscriptUtterance
Deserialize a JSON object to an instance of TranscriptUtterance
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 62 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) confidence = struct["confidence"] start = struct["start"] end_ = struct["end"] text = struct["text"] words = parsed_json["words"]&.map do |v| v = v.to_json AssemblyAI::Transcripts::TranscriptWord.from_json(json_object: v) end speaker = struct["speaker"] new( confidence: confidence, start: start, end_: end_, text: text, words: words, speaker: speaker, 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.
98 99 100 101 102 103 104 105 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 98 def self.validate_raw(obj:) obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence 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.text.is_a?(String) != false || raise("Passed value for field obj.text 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.") obj.speaker.is_a?(String) != false || raise("Passed value for field obj.speaker is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of TranscriptUtterance to a JSON object
88 89 90 |
# File 'lib/assemblyai/transcripts/types/transcript_utterance.rb', line 88 def to_json(*_args) @_field_set&.to_json end |