assemblyai 1.0.0.pre.beta.6 → 1.0.0.pre.beta.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assemblyai/files/client.rb +4 -2
- data/lib/assemblyai/files/types/uploaded_file.rb +20 -11
- data/lib/assemblyai/lemur/client.rb +256 -150
- data/lib/assemblyai/lemur/types/lemur_action_items_response.rb +28 -14
- data/lib/assemblyai/lemur/types/lemur_base_params.rb +83 -54
- data/lib/assemblyai/lemur/types/lemur_base_params_context.rb +11 -5
- data/lib/assemblyai/lemur/types/lemur_base_response.rb +20 -11
- data/lib/assemblyai/lemur/types/lemur_question.rb +57 -31
- data/lib/assemblyai/lemur/types/lemur_question_answer.rb +28 -14
- data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +29 -14
- data/lib/assemblyai/lemur/types/lemur_question_context.rb +13 -6
- data/lib/assemblyai/lemur/types/lemur_summary_response.rb +28 -14
- data/lib/assemblyai/lemur/types/lemur_task_response.rb +28 -14
- data/lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb +32 -17
- data/lib/assemblyai/realtime/client.rb +32 -16
- data/lib/assemblyai/realtime/types/configure_end_utterance_silence_threshold.rb +24 -13
- data/lib/assemblyai/realtime/types/final_transcript.rb +72 -41
- data/lib/assemblyai/realtime/types/force_end_utterance.rb +20 -11
- data/lib/assemblyai/realtime/types/message_type.rb +1 -0
- data/lib/assemblyai/realtime/types/partial_transcript.rb +62 -34
- data/lib/assemblyai/realtime/types/realtime_base_message.rb +22 -13
- data/lib/assemblyai/realtime/types/realtime_base_transcript.rb +57 -31
- data/lib/assemblyai/realtime/types/realtime_error.rb +20 -11
- data/lib/assemblyai/realtime/types/realtime_message.rb +44 -18
- data/lib/assemblyai/realtime/types/realtime_temporary_token_response.rb +21 -12
- data/lib/assemblyai/realtime/types/realtime_transcript.rb +15 -9
- data/lib/assemblyai/realtime/types/session_begins.rb +31 -14
- data/lib/assemblyai/realtime/types/session_information.rb +69 -0
- data/lib/assemblyai/realtime/types/session_terminated.rb +20 -11
- data/lib/assemblyai/realtime/types/terminate_session.rb +21 -12
- data/lib/assemblyai/realtime/types/word.rb +36 -18
- data/lib/assemblyai/streaming/types/receive_message.rb +113 -0
- data/lib/assemblyai/streaming/types/send_message.rb +86 -0
- data/lib/assemblyai/streaming/types/streaming.rb +11 -0
- data/lib/assemblyai/transcripts/client.rb +54 -20
- data/lib/assemblyai/transcripts/list_by_url_client.rb +6 -4
- data/lib/assemblyai/transcripts/polling_client.rb +12 -2
- data/lib/assemblyai/transcripts/types/auto_highlight_result.rb +40 -19
- data/lib/assemblyai/transcripts/types/auto_highlights_result.rb +38 -14
- data/lib/assemblyai/transcripts/types/chapter.rb +40 -20
- data/lib/assemblyai/transcripts/types/content_safety_label.rb +32 -16
- data/lib/assemblyai/transcripts/types/content_safety_label_result.rb +51 -29
- data/lib/assemblyai/transcripts/types/content_safety_labels_result.rb +51 -29
- data/lib/assemblyai/transcripts/types/entity.rb +41 -21
- data/lib/assemblyai/transcripts/types/page_details.rb +60 -33
- data/lib/assemblyai/transcripts/types/paragraphs_response.rb +37 -19
- data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +4 -1
- data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +29 -15
- data/lib/assemblyai/transcripts/types/sentences_response.rb +37 -19
- data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +62 -35
- data/lib/assemblyai/transcripts/types/severity_score_summary.rb +32 -16
- data/lib/assemblyai/transcripts/types/speech_model.rb +2 -0
- data/lib/assemblyai/transcripts/types/substitution_policy.rb +4 -2
- data/lib/assemblyai/transcripts/types/timestamp.rb +28 -14
- data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +39 -19
- data/lib/assemblyai/transcripts/types/topic_detection_result.rb +40 -21
- data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +31 -15
- data/lib/assemblyai/transcripts/types/transcript.rb +512 -293
- data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +30 -15
- data/lib/assemblyai/transcripts/types/transcript_language_code.rb +3 -2
- data/lib/assemblyai/transcripts/types/transcript_list.rb +33 -16
- data/lib/assemblyai/transcripts/types/transcript_list_item.rb +63 -30
- data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +334 -191
- data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +61 -33
- data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +30 -16
- data/lib/assemblyai/transcripts/types/transcript_sentence.rb +61 -33
- data/lib/assemblyai/transcripts/types/transcript_status.rb +2 -1
- data/lib/assemblyai/transcripts/types/transcript_utterance.rb +55 -31
- data/lib/assemblyai/transcripts/types/transcript_word.rb +55 -24
- data/lib/assemblyai/transcripts/types/word_search_match.rb +40 -20
- data/lib/assemblyai/transcripts/types/word_search_response.rb +36 -17
- data/lib/assemblyai/types/error.rb +32 -16
- data/lib/requests.rb +80 -34
- data/lib/types_export.rb +9 -8
- metadata +6 -5
- data/lib/assemblyai/realtime/types/audio_data.rb +0 -7
- data/lib/assemblyai/realtime/types/receive_message.rb +0 -87
- data/lib/assemblyai/realtime/types/send_message.rb +0 -74
@@ -1,73 +1,101 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "transcript_word"
|
4
|
+
require "ostruct"
|
4
5
|
require "json"
|
5
6
|
|
6
7
|
module AssemblyAI
|
7
8
|
class Transcripts
|
8
9
|
class TranscriptParagraph
|
9
|
-
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :text
|
12
|
+
# @return [Integer]
|
13
|
+
attr_reader :start
|
14
|
+
# @return [Integer]
|
15
|
+
attr_reader :end_
|
16
|
+
# @return [Float]
|
17
|
+
attr_reader :confidence
|
18
|
+
# @return [Array<AssemblyAI::Transcripts::TranscriptWord>]
|
19
|
+
attr_reader :words
|
20
|
+
# @return [String] The speaker of the sentence if [Speaker
|
21
|
+
# Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is
|
22
|
+
# enabled, else null
|
23
|
+
attr_reader :speaker
|
24
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
25
|
+
attr_reader :additional_properties
|
26
|
+
# @return [Object]
|
27
|
+
attr_reader :_field_set
|
28
|
+
protected :_field_set
|
29
|
+
|
30
|
+
OMIT = Object.new
|
10
31
|
|
11
32
|
# @param text [String]
|
12
33
|
# @param start [Integer]
|
13
34
|
# @param end_ [Integer]
|
14
35
|
# @param confidence [Float]
|
15
|
-
# @param words [Array<Transcripts::TranscriptWord>]
|
16
|
-
# @param speaker [String] The speaker of the sentence if [Speaker
|
36
|
+
# @param words [Array<AssemblyAI::Transcripts::TranscriptWord>]
|
37
|
+
# @param speaker [String] The speaker of the sentence if [Speaker
|
38
|
+
# Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is
|
39
|
+
# enabled, else null
|
17
40
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
18
|
-
# @return [Transcripts::TranscriptParagraph]
|
19
|
-
def initialize(text:, start:, end_:, confidence:, words:, speaker:
|
20
|
-
# @type [String]
|
41
|
+
# @return [AssemblyAI::Transcripts::TranscriptParagraph]
|
42
|
+
def initialize(text:, start:, end_:, confidence:, words:, speaker: OMIT, additional_properties: nil)
|
21
43
|
@text = text
|
22
|
-
# @type [Integer]
|
23
44
|
@start = start
|
24
|
-
# @type [Integer]
|
25
45
|
@end_ = end_
|
26
|
-
# @type [Float]
|
27
46
|
@confidence = confidence
|
28
|
-
# @type [Array<Transcripts::TranscriptWord>]
|
29
47
|
@words = words
|
30
|
-
|
31
|
-
@speaker = speaker
|
32
|
-
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
48
|
+
@speaker = speaker if speaker != OMIT
|
33
49
|
@additional_properties = additional_properties
|
50
|
+
@_field_set = {
|
51
|
+
"text": text,
|
52
|
+
"start": start,
|
53
|
+
"end": end_,
|
54
|
+
"confidence": confidence,
|
55
|
+
"words": words,
|
56
|
+
"speaker": speaker
|
57
|
+
}.reject do |_k, v|
|
58
|
+
v == OMIT
|
59
|
+
end
|
34
60
|
end
|
35
61
|
|
36
62
|
# Deserialize a JSON object to an instance of TranscriptParagraph
|
37
63
|
#
|
38
|
-
# @param json_object [
|
39
|
-
# @return [Transcripts::TranscriptParagraph]
|
64
|
+
# @param json_object [String]
|
65
|
+
# @return [AssemblyAI::Transcripts::TranscriptParagraph]
|
40
66
|
def self.from_json(json_object:)
|
41
67
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
42
68
|
parsed_json = JSON.parse(json_object)
|
43
|
-
text = struct
|
44
|
-
start = struct
|
45
|
-
end_ = struct
|
46
|
-
confidence = struct
|
69
|
+
text = struct["text"]
|
70
|
+
start = struct["start"]
|
71
|
+
end_ = struct["end"]
|
72
|
+
confidence = struct["confidence"]
|
47
73
|
words = parsed_json["words"]&.map do |v|
|
48
74
|
v = v.to_json
|
49
|
-
Transcripts::TranscriptWord.from_json(json_object: v)
|
75
|
+
AssemblyAI::Transcripts::TranscriptWord.from_json(json_object: v)
|
50
76
|
end
|
51
|
-
speaker = struct
|
52
|
-
new(
|
53
|
-
|
77
|
+
speaker = struct["speaker"]
|
78
|
+
new(
|
79
|
+
text: text,
|
80
|
+
start: start,
|
81
|
+
end_: end_,
|
82
|
+
confidence: confidence,
|
83
|
+
words: words,
|
84
|
+
speaker: speaker,
|
85
|
+
additional_properties: struct
|
86
|
+
)
|
54
87
|
end
|
55
88
|
|
56
89
|
# Serialize an instance of TranscriptParagraph to a JSON object
|
57
90
|
#
|
58
|
-
# @return [
|
91
|
+
# @return [String]
|
59
92
|
def to_json(*_args)
|
60
|
-
|
61
|
-
"text": @text,
|
62
|
-
"start": @start,
|
63
|
-
"end": @end_,
|
64
|
-
"confidence": @confidence,
|
65
|
-
"words": @words,
|
66
|
-
"speaker": @speaker
|
67
|
-
}.to_json
|
93
|
+
@_field_set&.to_json
|
68
94
|
end
|
69
95
|
|
70
|
-
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
96
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
97
|
+
# hash and check each fields type against the current object's property
|
98
|
+
# definitions.
|
71
99
|
#
|
72
100
|
# @param obj [Object]
|
73
101
|
# @return [Void]
|
@@ -1,53 +1,67 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "transcript_ready_status"
|
4
|
+
require "ostruct"
|
4
5
|
require "json"
|
5
6
|
|
6
7
|
module AssemblyAI
|
7
8
|
class Transcripts
|
8
9
|
# The notification when the transcript status is completed or error.
|
9
10
|
class TranscriptReadyNotification
|
10
|
-
|
11
|
+
# @return [String] The ID of the transcript
|
12
|
+
attr_reader :transcript_id
|
13
|
+
# @return [AssemblyAI::Transcripts::TranscriptReadyStatus] The status of the transcript. Either completed or error.
|
14
|
+
attr_reader :status
|
15
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
16
|
+
attr_reader :additional_properties
|
17
|
+
# @return [Object]
|
18
|
+
attr_reader :_field_set
|
19
|
+
protected :_field_set
|
20
|
+
|
21
|
+
OMIT = Object.new
|
11
22
|
|
12
23
|
# @param transcript_id [String] The ID of the transcript
|
13
|
-
# @param status [Transcripts::TranscriptReadyStatus] The status of the transcript. Either completed or error.
|
24
|
+
# @param status [AssemblyAI::Transcripts::TranscriptReadyStatus] The status of the transcript. Either completed or error.
|
14
25
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
15
|
-
# @return [Transcripts::TranscriptReadyNotification]
|
26
|
+
# @return [AssemblyAI::Transcripts::TranscriptReadyNotification]
|
16
27
|
def initialize(transcript_id:, status:, additional_properties: nil)
|
17
|
-
# @type [String] The ID of the transcript
|
18
28
|
@transcript_id = transcript_id
|
19
|
-
# @type [Transcripts::TranscriptReadyStatus] The status of the transcript. Either completed or error.
|
20
29
|
@status = status
|
21
|
-
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
22
30
|
@additional_properties = additional_properties
|
31
|
+
@_field_set = { "transcript_id": transcript_id, "status": status }
|
23
32
|
end
|
24
33
|
|
25
34
|
# Deserialize a JSON object to an instance of TranscriptReadyNotification
|
26
35
|
#
|
27
|
-
# @param json_object [
|
28
|
-
# @return [Transcripts::TranscriptReadyNotification]
|
36
|
+
# @param json_object [String]
|
37
|
+
# @return [AssemblyAI::Transcripts::TranscriptReadyNotification]
|
29
38
|
def self.from_json(json_object:)
|
30
39
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
40
|
+
transcript_id = struct["transcript_id"]
|
41
|
+
status = struct["status"]
|
42
|
+
new(
|
43
|
+
transcript_id: transcript_id,
|
44
|
+
status: status,
|
45
|
+
additional_properties: struct
|
46
|
+
)
|
35
47
|
end
|
36
48
|
|
37
49
|
# Serialize an instance of TranscriptReadyNotification to a JSON object
|
38
50
|
#
|
39
|
-
# @return [
|
51
|
+
# @return [String]
|
40
52
|
def to_json(*_args)
|
41
|
-
|
53
|
+
@_field_set&.to_json
|
42
54
|
end
|
43
55
|
|
44
|
-
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
56
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
57
|
+
# hash and check each fields type against the current object's property
|
58
|
+
# definitions.
|
45
59
|
#
|
46
60
|
# @param obj [Object]
|
47
61
|
# @return [Void]
|
48
62
|
def self.validate_raw(obj:)
|
49
63
|
obj.transcript_id.is_a?(String) != false || raise("Passed value for field obj.transcript_id is not the expected type, validation failed.")
|
50
|
-
obj.status.is_a?(Transcripts::TranscriptReadyStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
64
|
+
obj.status.is_a?(AssemblyAI::Transcripts::TranscriptReadyStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
51
65
|
end
|
52
66
|
end
|
53
67
|
end
|
@@ -1,73 +1,101 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "transcript_word"
|
4
|
+
require "ostruct"
|
4
5
|
require "json"
|
5
6
|
|
6
7
|
module AssemblyAI
|
7
8
|
class Transcripts
|
8
9
|
class TranscriptSentence
|
9
|
-
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :text
|
12
|
+
# @return [Integer]
|
13
|
+
attr_reader :start
|
14
|
+
# @return [Integer]
|
15
|
+
attr_reader :end_
|
16
|
+
# @return [Float]
|
17
|
+
attr_reader :confidence
|
18
|
+
# @return [Array<AssemblyAI::Transcripts::TranscriptWord>]
|
19
|
+
attr_reader :words
|
20
|
+
# @return [String] The speaker of the sentence if [Speaker
|
21
|
+
# Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is
|
22
|
+
# enabled, else null
|
23
|
+
attr_reader :speaker
|
24
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
25
|
+
attr_reader :additional_properties
|
26
|
+
# @return [Object]
|
27
|
+
attr_reader :_field_set
|
28
|
+
protected :_field_set
|
29
|
+
|
30
|
+
OMIT = Object.new
|
10
31
|
|
11
32
|
# @param text [String]
|
12
33
|
# @param start [Integer]
|
13
34
|
# @param end_ [Integer]
|
14
35
|
# @param confidence [Float]
|
15
|
-
# @param words [Array<Transcripts::TranscriptWord>]
|
16
|
-
# @param speaker [String] The speaker of the sentence if [Speaker
|
36
|
+
# @param words [Array<AssemblyAI::Transcripts::TranscriptWord>]
|
37
|
+
# @param speaker [String] The speaker of the sentence if [Speaker
|
38
|
+
# Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is
|
39
|
+
# enabled, else null
|
17
40
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
18
|
-
# @return [Transcripts::TranscriptSentence]
|
19
|
-
def initialize(text:, start:, end_:, confidence:, words:, speaker:
|
20
|
-
# @type [String]
|
41
|
+
# @return [AssemblyAI::Transcripts::TranscriptSentence]
|
42
|
+
def initialize(text:, start:, end_:, confidence:, words:, speaker: OMIT, additional_properties: nil)
|
21
43
|
@text = text
|
22
|
-
# @type [Integer]
|
23
44
|
@start = start
|
24
|
-
# @type [Integer]
|
25
45
|
@end_ = end_
|
26
|
-
# @type [Float]
|
27
46
|
@confidence = confidence
|
28
|
-
# @type [Array<Transcripts::TranscriptWord>]
|
29
47
|
@words = words
|
30
|
-
|
31
|
-
@speaker = speaker
|
32
|
-
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
48
|
+
@speaker = speaker if speaker != OMIT
|
33
49
|
@additional_properties = additional_properties
|
50
|
+
@_field_set = {
|
51
|
+
"text": text,
|
52
|
+
"start": start,
|
53
|
+
"end": end_,
|
54
|
+
"confidence": confidence,
|
55
|
+
"words": words,
|
56
|
+
"speaker": speaker
|
57
|
+
}.reject do |_k, v|
|
58
|
+
v == OMIT
|
59
|
+
end
|
34
60
|
end
|
35
61
|
|
36
62
|
# Deserialize a JSON object to an instance of TranscriptSentence
|
37
63
|
#
|
38
|
-
# @param json_object [
|
39
|
-
# @return [Transcripts::TranscriptSentence]
|
64
|
+
# @param json_object [String]
|
65
|
+
# @return [AssemblyAI::Transcripts::TranscriptSentence]
|
40
66
|
def self.from_json(json_object:)
|
41
67
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
42
68
|
parsed_json = JSON.parse(json_object)
|
43
|
-
text = struct
|
44
|
-
start = struct
|
45
|
-
end_ = struct
|
46
|
-
confidence = struct
|
69
|
+
text = struct["text"]
|
70
|
+
start = struct["start"]
|
71
|
+
end_ = struct["end"]
|
72
|
+
confidence = struct["confidence"]
|
47
73
|
words = parsed_json["words"]&.map do |v|
|
48
74
|
v = v.to_json
|
49
|
-
Transcripts::TranscriptWord.from_json(json_object: v)
|
75
|
+
AssemblyAI::Transcripts::TranscriptWord.from_json(json_object: v)
|
50
76
|
end
|
51
|
-
speaker = struct
|
52
|
-
new(
|
53
|
-
|
77
|
+
speaker = struct["speaker"]
|
78
|
+
new(
|
79
|
+
text: text,
|
80
|
+
start: start,
|
81
|
+
end_: end_,
|
82
|
+
confidence: confidence,
|
83
|
+
words: words,
|
84
|
+
speaker: speaker,
|
85
|
+
additional_properties: struct
|
86
|
+
)
|
54
87
|
end
|
55
88
|
|
56
89
|
# Serialize an instance of TranscriptSentence to a JSON object
|
57
90
|
#
|
58
|
-
# @return [
|
91
|
+
# @return [String]
|
59
92
|
def to_json(*_args)
|
60
|
-
|
61
|
-
"text": @text,
|
62
|
-
"start": @start,
|
63
|
-
"end": @end_,
|
64
|
-
"confidence": @confidence,
|
65
|
-
"words": @words,
|
66
|
-
"speaker": @speaker
|
67
|
-
}.to_json
|
93
|
+
@_field_set&.to_json
|
68
94
|
end
|
69
95
|
|
70
|
-
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
96
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
97
|
+
# hash and check each fields type against the current object's property
|
98
|
+
# definitions.
|
71
99
|
#
|
72
100
|
# @param obj [Object]
|
73
101
|
# @return [Void]
|
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
module AssemblyAI
|
4
4
|
class Transcripts
|
5
|
-
# The status of your transcript. Possible values are queued, processing,
|
5
|
+
# The status of your transcript. Possible values are queued, processing,
|
6
|
+
# completed, or error.
|
6
7
|
class TranscriptStatus
|
7
8
|
QUEUED = "queued"
|
8
9
|
PROCESSING = "processing"
|
@@ -1,73 +1,97 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "transcript_word"
|
4
|
+
require "ostruct"
|
4
5
|
require "json"
|
5
6
|
|
6
7
|
module AssemblyAI
|
7
8
|
class Transcripts
|
8
9
|
class TranscriptUtterance
|
9
|
-
|
10
|
+
# @return [Float] The confidence score for the transcript of this utterance
|
11
|
+
attr_reader :confidence
|
12
|
+
# @return [Integer] The starting time, in milliseconds, of the utterance in the audio file
|
13
|
+
attr_reader :start
|
14
|
+
# @return [Integer] The ending time, in milliseconds, of the utterance in the audio file
|
15
|
+
attr_reader :end_
|
16
|
+
# @return [String] The text for this utterance
|
17
|
+
attr_reader :text
|
18
|
+
# @return [Array<AssemblyAI::Transcripts::TranscriptWord>] The words in the utterance.
|
19
|
+
attr_reader :words
|
20
|
+
# @return [String] The speaker of this utterance, where each speaker is assigned a sequential
|
21
|
+
# capital letter - e.g. "A" for Speaker A, "B" for Speaker B, etc.
|
22
|
+
attr_reader :speaker
|
23
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
24
|
+
attr_reader :additional_properties
|
25
|
+
# @return [Object]
|
26
|
+
attr_reader :_field_set
|
27
|
+
protected :_field_set
|
28
|
+
|
29
|
+
OMIT = Object.new
|
10
30
|
|
11
31
|
# @param confidence [Float] The confidence score for the transcript of this utterance
|
12
32
|
# @param start [Integer] The starting time, in milliseconds, of the utterance in the audio file
|
13
33
|
# @param end_ [Integer] The ending time, in milliseconds, of the utterance in the audio file
|
14
34
|
# @param text [String] The text for this utterance
|
15
|
-
# @param words [Array<Transcripts::TranscriptWord>] The words in the utterance.
|
16
|
-
# @param speaker [String] The speaker of this utterance, where each speaker is assigned a sequential
|
35
|
+
# @param words [Array<AssemblyAI::Transcripts::TranscriptWord>] The words in the utterance.
|
36
|
+
# @param speaker [String] The speaker of this utterance, where each speaker is assigned a sequential
|
37
|
+
# capital letter - e.g. "A" for Speaker A, "B" for Speaker B, etc.
|
17
38
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
18
|
-
# @return [Transcripts::TranscriptUtterance]
|
39
|
+
# @return [AssemblyAI::Transcripts::TranscriptUtterance]
|
19
40
|
def initialize(confidence:, start:, end_:, text:, words:, speaker:, additional_properties: nil)
|
20
|
-
# @type [Float] The confidence score for the transcript of this utterance
|
21
41
|
@confidence = confidence
|
22
|
-
# @type [Integer] The starting time, in milliseconds, of the utterance in the audio file
|
23
42
|
@start = start
|
24
|
-
# @type [Integer] The ending time, in milliseconds, of the utterance in the audio file
|
25
43
|
@end_ = end_
|
26
|
-
# @type [String] The text for this utterance
|
27
44
|
@text = text
|
28
|
-
# @type [Array<Transcripts::TranscriptWord>] The words in the utterance.
|
29
45
|
@words = words
|
30
|
-
# @type [String] 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.
|
31
46
|
@speaker = speaker
|
32
|
-
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
33
47
|
@additional_properties = additional_properties
|
48
|
+
@_field_set = {
|
49
|
+
"confidence": confidence,
|
50
|
+
"start": start,
|
51
|
+
"end": end_,
|
52
|
+
"text": text,
|
53
|
+
"words": words,
|
54
|
+
"speaker": speaker
|
55
|
+
}
|
34
56
|
end
|
35
57
|
|
36
58
|
# Deserialize a JSON object to an instance of TranscriptUtterance
|
37
59
|
#
|
38
|
-
# @param json_object [
|
39
|
-
# @return [Transcripts::TranscriptUtterance]
|
60
|
+
# @param json_object [String]
|
61
|
+
# @return [AssemblyAI::Transcripts::TranscriptUtterance]
|
40
62
|
def self.from_json(json_object:)
|
41
63
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
42
64
|
parsed_json = JSON.parse(json_object)
|
43
|
-
confidence = struct
|
44
|
-
start = struct
|
45
|
-
end_ = struct
|
46
|
-
text = struct
|
65
|
+
confidence = struct["confidence"]
|
66
|
+
start = struct["start"]
|
67
|
+
end_ = struct["end"]
|
68
|
+
text = struct["text"]
|
47
69
|
words = parsed_json["words"]&.map do |v|
|
48
70
|
v = v.to_json
|
49
|
-
Transcripts::TranscriptWord.from_json(json_object: v)
|
71
|
+
AssemblyAI::Transcripts::TranscriptWord.from_json(json_object: v)
|
50
72
|
end
|
51
|
-
speaker = struct
|
52
|
-
new(
|
53
|
-
|
73
|
+
speaker = struct["speaker"]
|
74
|
+
new(
|
75
|
+
confidence: confidence,
|
76
|
+
start: start,
|
77
|
+
end_: end_,
|
78
|
+
text: text,
|
79
|
+
words: words,
|
80
|
+
speaker: speaker,
|
81
|
+
additional_properties: struct
|
82
|
+
)
|
54
83
|
end
|
55
84
|
|
56
85
|
# Serialize an instance of TranscriptUtterance to a JSON object
|
57
86
|
#
|
58
|
-
# @return [
|
87
|
+
# @return [String]
|
59
88
|
def to_json(*_args)
|
60
|
-
|
61
|
-
"confidence": @confidence,
|
62
|
-
"start": @start,
|
63
|
-
"end": @end_,
|
64
|
-
"text": @text,
|
65
|
-
"words": @words,
|
66
|
-
"speaker": @speaker
|
67
|
-
}.to_json
|
89
|
+
@_field_set&.to_json
|
68
90
|
end
|
69
91
|
|
70
|
-
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
92
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
93
|
+
# hash and check each fields type against the current object's property
|
94
|
+
# definitions.
|
71
95
|
#
|
72
96
|
# @param obj [Object]
|
73
97
|
# @return [Void]
|
@@ -1,58 +1,89 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "ostruct"
|
3
4
|
require "json"
|
4
5
|
|
5
6
|
module AssemblyAI
|
6
7
|
class Transcripts
|
7
8
|
class TranscriptWord
|
8
|
-
|
9
|
+
# @return [Float]
|
10
|
+
attr_reader :confidence
|
11
|
+
# @return [Integer]
|
12
|
+
attr_reader :start
|
13
|
+
# @return [Integer]
|
14
|
+
attr_reader :end_
|
15
|
+
# @return [String]
|
16
|
+
attr_reader :text
|
17
|
+
# @return [String] The speaker of the sentence if [Speaker
|
18
|
+
# Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is
|
19
|
+
# enabled, else null
|
20
|
+
attr_reader :speaker
|
21
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
22
|
+
attr_reader :additional_properties
|
23
|
+
# @return [Object]
|
24
|
+
attr_reader :_field_set
|
25
|
+
protected :_field_set
|
26
|
+
|
27
|
+
OMIT = Object.new
|
9
28
|
|
10
29
|
# @param confidence [Float]
|
11
30
|
# @param start [Integer]
|
12
31
|
# @param end_ [Integer]
|
13
32
|
# @param text [String]
|
14
|
-
# @param speaker [String] The speaker of the sentence if [Speaker
|
33
|
+
# @param speaker [String] The speaker of the sentence if [Speaker
|
34
|
+
# Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is
|
35
|
+
# enabled, else null
|
15
36
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
16
|
-
# @return [Transcripts::TranscriptWord]
|
17
|
-
def initialize(confidence:, start:, end_:, text:, speaker:
|
18
|
-
# @type [Float]
|
37
|
+
# @return [AssemblyAI::Transcripts::TranscriptWord]
|
38
|
+
def initialize(confidence:, start:, end_:, text:, speaker: OMIT, additional_properties: nil)
|
19
39
|
@confidence = confidence
|
20
|
-
# @type [Integer]
|
21
40
|
@start = start
|
22
|
-
# @type [Integer]
|
23
41
|
@end_ = end_
|
24
|
-
# @type [String]
|
25
42
|
@text = text
|
26
|
-
|
27
|
-
@speaker = speaker
|
28
|
-
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
43
|
+
@speaker = speaker if speaker != OMIT
|
29
44
|
@additional_properties = additional_properties
|
45
|
+
@_field_set = {
|
46
|
+
"confidence": confidence,
|
47
|
+
"start": start,
|
48
|
+
"end": end_,
|
49
|
+
"text": text,
|
50
|
+
"speaker": speaker
|
51
|
+
}.reject do |_k, v|
|
52
|
+
v == OMIT
|
53
|
+
end
|
30
54
|
end
|
31
55
|
|
32
56
|
# Deserialize a JSON object to an instance of TranscriptWord
|
33
57
|
#
|
34
|
-
# @param json_object [
|
35
|
-
# @return [Transcripts::TranscriptWord]
|
58
|
+
# @param json_object [String]
|
59
|
+
# @return [AssemblyAI::Transcripts::TranscriptWord]
|
36
60
|
def self.from_json(json_object:)
|
37
61
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
62
|
+
confidence = struct["confidence"]
|
63
|
+
start = struct["start"]
|
64
|
+
end_ = struct["end"]
|
65
|
+
text = struct["text"]
|
66
|
+
speaker = struct["speaker"]
|
67
|
+
new(
|
68
|
+
confidence: confidence,
|
69
|
+
start: start,
|
70
|
+
end_: end_,
|
71
|
+
text: text,
|
72
|
+
speaker: speaker,
|
73
|
+
additional_properties: struct
|
74
|
+
)
|
46
75
|
end
|
47
76
|
|
48
77
|
# Serialize an instance of TranscriptWord to a JSON object
|
49
78
|
#
|
50
|
-
# @return [
|
79
|
+
# @return [String]
|
51
80
|
def to_json(*_args)
|
52
|
-
|
81
|
+
@_field_set&.to_json
|
53
82
|
end
|
54
83
|
|
55
|
-
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
84
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
85
|
+
# hash and check each fields type against the current object's property
|
86
|
+
# definitions.
|
56
87
|
#
|
57
88
|
# @param obj [Object]
|
58
89
|
# @return [Void]
|