assemblyai 1.0.0.pre.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/assemblyai/files/client.rb +63 -0
- data/lib/assemblyai/files/types/uploaded_file.rb +47 -0
- data/lib/assemblyai/lemur/client.rb +390 -0
- data/lib/assemblyai/lemur/types/lemur_action_items_response.rb +52 -0
- data/lib/assemblyai/lemur/types/lemur_base_params.rb +99 -0
- data/lib/assemblyai/lemur/types/lemur_base_params_context.rb +75 -0
- data/lib/assemblyai/lemur/types/lemur_base_response.rb +47 -0
- data/lib/assemblyai/lemur/types/lemur_model.rb +13 -0
- data/lib/assemblyai/lemur/types/lemur_question.rb +74 -0
- data/lib/assemblyai/lemur/types/lemur_question_answer.rb +53 -0
- data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +56 -0
- data/lib/assemblyai/lemur/types/lemur_question_context.rb +75 -0
- data/lib/assemblyai/lemur/types/lemur_summary_response.rb +52 -0
- data/lib/assemblyai/lemur/types/lemur_task_response.rb +52 -0
- data/lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb +58 -0
- data/lib/assemblyai/realtime/client.rb +61 -0
- data/lib/assemblyai/realtime/types/audio_data.rb +7 -0
- data/lib/assemblyai/realtime/types/audio_encoding.rb +8 -0
- data/lib/assemblyai/realtime/types/final_transcript.rb +107 -0
- data/lib/assemblyai/realtime/types/message_type.rb +13 -0
- data/lib/assemblyai/realtime/types/partial_transcript.rb +94 -0
- data/lib/assemblyai/realtime/types/realtime_base_message.rb +48 -0
- data/lib/assemblyai/realtime/types/realtime_base_transcript.rb +87 -0
- data/lib/assemblyai/realtime/types/realtime_error.rb +47 -0
- data/lib/assemblyai/realtime/types/realtime_message.rb +115 -0
- data/lib/assemblyai/realtime/types/realtime_temporary_token_response.rb +47 -0
- data/lib/assemblyai/realtime/types/realtime_transcript.rb +76 -0
- data/lib/assemblyai/realtime/types/realtime_transcript_type.rb +8 -0
- data/lib/assemblyai/realtime/types/session_begins.rb +58 -0
- data/lib/assemblyai/realtime/types/session_terminated.rb +47 -0
- data/lib/assemblyai/realtime/types/terminate_session.rb +56 -0
- data/lib/assemblyai/realtime/types/word.rb +62 -0
- data/lib/assemblyai/transcripts/client.rb +525 -0
- data/lib/assemblyai/transcripts/polling_client.rb +173 -0
- data/lib/assemblyai/transcripts/types/audio_intelligence_model_status.rb +8 -0
- data/lib/assemblyai/transcripts/types/auto_highlight_result.rb +66 -0
- data/lib/assemblyai/transcripts/types/auto_highlights_result.rb +53 -0
- data/lib/assemblyai/transcripts/types/chapter.rb +68 -0
- data/lib/assemblyai/transcripts/types/content_safety_label.rb +57 -0
- data/lib/assemblyai/transcripts/types/content_safety_label_result.rb +84 -0
- data/lib/assemblyai/transcripts/types/content_safety_labels_result.rb +75 -0
- data/lib/assemblyai/transcripts/types/entity.rb +69 -0
- data/lib/assemblyai/transcripts/types/entity_type.rb +38 -0
- data/lib/assemblyai/transcripts/types/page_details.rb +74 -0
- data/lib/assemblyai/transcripts/types/paragraphs_response.rb +67 -0
- data/lib/assemblyai/transcripts/types/pii_policy.rb +36 -0
- data/lib/assemblyai/transcripts/types/polling_options.rb +21 -0
- data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +8 -0
- data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +53 -0
- data/lib/assemblyai/transcripts/types/redacted_audio_status.rb +7 -0
- data/lib/assemblyai/transcripts/types/sentences_response.rb +67 -0
- data/lib/assemblyai/transcripts/types/sentiment.rb +8 -0
- data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +82 -0
- data/lib/assemblyai/transcripts/types/severity_score_summary.rb +57 -0
- data/lib/assemblyai/transcripts/types/speech_model.rb +7 -0
- data/lib/assemblyai/transcripts/types/substitution_policy.rb +8 -0
- data/lib/assemblyai/transcripts/types/subtitle_format.rb +8 -0
- data/lib/assemblyai/transcripts/types/summary_model.rb +8 -0
- data/lib/assemblyai/transcripts/types/summary_type.rb +14 -0
- data/lib/assemblyai/transcripts/types/timestamp.rb +53 -0
- data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +68 -0
- data/lib/assemblyai/transcripts/types/topic_detection_result.rb +68 -0
- data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +52 -0
- data/lib/assemblyai/transcripts/types/transcript.rb +454 -0
- data/lib/assemblyai/transcripts/types/transcript_boost_param.rb +8 -0
- data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +53 -0
- data/lib/assemblyai/transcripts/types/transcript_language_code.rb +29 -0
- data/lib/assemblyai/transcripts/types/transcript_list.rb +62 -0
- data/lib/assemblyai/transcripts/types/transcript_list_item.rb +82 -0
- data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +280 -0
- data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +84 -0
- data/lib/assemblyai/transcripts/types/transcript_sentence.rb +84 -0
- data/lib/assemblyai/transcripts/types/transcript_status.rb +8 -0
- data/lib/assemblyai/transcripts/types/transcript_utterance.rb +84 -0
- data/lib/assemblyai/transcripts/types/transcript_word.rb +68 -0
- data/lib/assemblyai/transcripts/types/word_search_match.rb +63 -0
- data/lib/assemblyai/transcripts/types/word_search_response.rb +61 -0
- data/lib/assemblyai/transcripts/types/word_search_timestamp.rb +7 -0
- data/lib/assemblyai/types/error.rb +50 -0
- data/lib/assemblyai.rb +48 -0
- data/lib/environment.rb +7 -0
- data/lib/gemconfig.rb +14 -0
- data/lib/requests.rb +87 -0
- data/lib/types_export.rb +75 -0
- metadata +170 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "word"
|
|
4
|
+
require "date"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module AssemblyAI
|
|
8
|
+
class Realtime
|
|
9
|
+
class FinalTranscript
|
|
10
|
+
attr_reader :message_type, :punctuated, :text_formatted, :audio_start, :audio_end, :confidence, :text, :words,
|
|
11
|
+
:created, :additional_properties
|
|
12
|
+
|
|
13
|
+
# @param message_type [String]
|
|
14
|
+
# @param punctuated [Boolean] Whether the text is punctuated and cased
|
|
15
|
+
# @param text_formatted [Boolean] Whether the text is formatted, for example Dollar -> $
|
|
16
|
+
# @param audio_start [Integer] Start time of audio sample relative to session start, in milliseconds
|
|
17
|
+
# @param audio_end [Integer] End time of audio sample relative to session start, in milliseconds
|
|
18
|
+
# @param confidence [Float] The confidence score of the entire transcription, between 0 and 1
|
|
19
|
+
# @param text [String] The partial transcript for your audio
|
|
20
|
+
# @param words [Array<Realtime::Word>] An array of objects, with the information for each word in the transcription text.
|
|
21
|
+
# Includes the start and end time of the word in milliseconds, the confidence score of the word, and the text, which is the word itself.
|
|
22
|
+
# @param created [DateTime] The timestamp for the partial transcript
|
|
23
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
24
|
+
# @return [Realtime::FinalTranscript]
|
|
25
|
+
def initialize(message_type:, punctuated:, text_formatted:, audio_start:, audio_end:, confidence:, text:, words:,
|
|
26
|
+
created:, additional_properties: nil)
|
|
27
|
+
# @type [String]
|
|
28
|
+
@message_type = message_type
|
|
29
|
+
# @type [Boolean] Whether the text is punctuated and cased
|
|
30
|
+
@punctuated = punctuated
|
|
31
|
+
# @type [Boolean] Whether the text is formatted, for example Dollar -> $
|
|
32
|
+
@text_formatted = text_formatted
|
|
33
|
+
# @type [Integer] Start time of audio sample relative to session start, in milliseconds
|
|
34
|
+
@audio_start = audio_start
|
|
35
|
+
# @type [Integer] End time of audio sample relative to session start, in milliseconds
|
|
36
|
+
@audio_end = audio_end
|
|
37
|
+
# @type [Float] The confidence score of the entire transcription, between 0 and 1
|
|
38
|
+
@confidence = confidence
|
|
39
|
+
# @type [String] The partial transcript for your audio
|
|
40
|
+
@text = text
|
|
41
|
+
# @type [Array<Realtime::Word>] An array of objects, with the information for each word in the transcription text.
|
|
42
|
+
# Includes the start and end time of the word in milliseconds, the confidence score of the word, and the text, which is the word itself.
|
|
43
|
+
@words = words
|
|
44
|
+
# @type [DateTime] The timestamp for the partial transcript
|
|
45
|
+
@created = created
|
|
46
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
47
|
+
@additional_properties = additional_properties
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Deserialize a JSON object to an instance of FinalTranscript
|
|
51
|
+
#
|
|
52
|
+
# @param json_object [JSON]
|
|
53
|
+
# @return [Realtime::FinalTranscript]
|
|
54
|
+
def self.from_json(json_object:)
|
|
55
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
56
|
+
parsed_json = JSON.parse(json_object)
|
|
57
|
+
message_type = struct.message_type
|
|
58
|
+
punctuated = struct.punctuated
|
|
59
|
+
text_formatted = struct.text_formatted
|
|
60
|
+
audio_start = struct.audio_start
|
|
61
|
+
audio_end = struct.audio_end
|
|
62
|
+
confidence = struct.confidence
|
|
63
|
+
text = struct.text
|
|
64
|
+
words = parsed_json["words"]&.map do |v|
|
|
65
|
+
v = v.to_json
|
|
66
|
+
Realtime::Word.from_json(json_object: v)
|
|
67
|
+
end
|
|
68
|
+
created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
|
|
69
|
+
new(message_type: message_type, punctuated: punctuated, text_formatted: text_formatted,
|
|
70
|
+
audio_start: audio_start, audio_end: audio_end, confidence: confidence, text: text, words: words, created: created, additional_properties: struct)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Serialize an instance of FinalTranscript to a JSON object
|
|
74
|
+
#
|
|
75
|
+
# @return [JSON]
|
|
76
|
+
def to_json(*_args)
|
|
77
|
+
{
|
|
78
|
+
"message_type": @message_type,
|
|
79
|
+
"punctuated": @punctuated,
|
|
80
|
+
"text_formatted": @text_formatted,
|
|
81
|
+
"audio_start": @audio_start,
|
|
82
|
+
"audio_end": @audio_end,
|
|
83
|
+
"confidence": @confidence,
|
|
84
|
+
"text": @text,
|
|
85
|
+
"words": @words,
|
|
86
|
+
"created": @created
|
|
87
|
+
}.to_json
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# 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.
|
|
91
|
+
#
|
|
92
|
+
# @param obj [Object]
|
|
93
|
+
# @return [Void]
|
|
94
|
+
def self.validate_raw(obj:)
|
|
95
|
+
obj.message_type.is_a?(String) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
|
|
96
|
+
obj.punctuated.is_a?(Boolean) != false || raise("Passed value for field obj.punctuated is not the expected type, validation failed.")
|
|
97
|
+
obj.text_formatted.is_a?(Boolean) != false || raise("Passed value for field obj.text_formatted is not the expected type, validation failed.")
|
|
98
|
+
obj.audio_start.is_a?(Integer) != false || raise("Passed value for field obj.audio_start is not the expected type, validation failed.")
|
|
99
|
+
obj.audio_end.is_a?(Integer) != false || raise("Passed value for field obj.audio_end is not the expected type, validation failed.")
|
|
100
|
+
obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
|
|
101
|
+
obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
|
|
102
|
+
obj.words.is_a?(Array) != false || raise("Passed value for field obj.words is not the expected type, validation failed.")
|
|
103
|
+
obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AssemblyAI
|
|
4
|
+
class Realtime
|
|
5
|
+
# @type [MESSAGE_TYPE]
|
|
6
|
+
MESSAGE_TYPE = {
|
|
7
|
+
session_begins: "SessionBegins",
|
|
8
|
+
partial_transcript: "PartialTranscript",
|
|
9
|
+
final_transcript: "FinalTranscript",
|
|
10
|
+
session_terminated: "SessionTerminated"
|
|
11
|
+
}.freeze
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "word"
|
|
4
|
+
require "date"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module AssemblyAI
|
|
8
|
+
class Realtime
|
|
9
|
+
class PartialTranscript
|
|
10
|
+
attr_reader :message_type, :audio_start, :audio_end, :confidence, :text, :words, :created, :additional_properties
|
|
11
|
+
|
|
12
|
+
# @param message_type [String]
|
|
13
|
+
# @param audio_start [Integer] Start time of audio sample relative to session start, in milliseconds
|
|
14
|
+
# @param audio_end [Integer] End time of audio sample relative to session start, in milliseconds
|
|
15
|
+
# @param confidence [Float] The confidence score of the entire transcription, between 0 and 1
|
|
16
|
+
# @param text [String] The partial transcript for your audio
|
|
17
|
+
# @param words [Array<Realtime::Word>] An array of objects, with the information for each word in the transcription text.
|
|
18
|
+
# Includes the start and end time of the word in milliseconds, the confidence score of the word, and the text, which is the word itself.
|
|
19
|
+
# @param created [DateTime] The timestamp for the partial transcript
|
|
20
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
21
|
+
# @return [Realtime::PartialTranscript]
|
|
22
|
+
def initialize(message_type:, audio_start:, audio_end:, confidence:, text:, words:, created:,
|
|
23
|
+
additional_properties: nil)
|
|
24
|
+
# @type [String]
|
|
25
|
+
@message_type = message_type
|
|
26
|
+
# @type [Integer] Start time of audio sample relative to session start, in milliseconds
|
|
27
|
+
@audio_start = audio_start
|
|
28
|
+
# @type [Integer] End time of audio sample relative to session start, in milliseconds
|
|
29
|
+
@audio_end = audio_end
|
|
30
|
+
# @type [Float] The confidence score of the entire transcription, between 0 and 1
|
|
31
|
+
@confidence = confidence
|
|
32
|
+
# @type [String] The partial transcript for your audio
|
|
33
|
+
@text = text
|
|
34
|
+
# @type [Array<Realtime::Word>] An array of objects, with the information for each word in the transcription text.
|
|
35
|
+
# Includes the start and end time of the word in milliseconds, the confidence score of the word, and the text, which is the word itself.
|
|
36
|
+
@words = words
|
|
37
|
+
# @type [DateTime] The timestamp for the partial transcript
|
|
38
|
+
@created = created
|
|
39
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
40
|
+
@additional_properties = additional_properties
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Deserialize a JSON object to an instance of PartialTranscript
|
|
44
|
+
#
|
|
45
|
+
# @param json_object [JSON]
|
|
46
|
+
# @return [Realtime::PartialTranscript]
|
|
47
|
+
def self.from_json(json_object:)
|
|
48
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
49
|
+
parsed_json = JSON.parse(json_object)
|
|
50
|
+
message_type = struct.message_type
|
|
51
|
+
audio_start = struct.audio_start
|
|
52
|
+
audio_end = struct.audio_end
|
|
53
|
+
confidence = struct.confidence
|
|
54
|
+
text = struct.text
|
|
55
|
+
words = parsed_json["words"]&.map do |v|
|
|
56
|
+
v = v.to_json
|
|
57
|
+
Realtime::Word.from_json(json_object: v)
|
|
58
|
+
end
|
|
59
|
+
created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
|
|
60
|
+
new(message_type: message_type, audio_start: audio_start, audio_end: audio_end, confidence: confidence,
|
|
61
|
+
text: text, words: words, created: created, additional_properties: struct)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Serialize an instance of PartialTranscript to a JSON object
|
|
65
|
+
#
|
|
66
|
+
# @return [JSON]
|
|
67
|
+
def to_json(*_args)
|
|
68
|
+
{
|
|
69
|
+
"message_type": @message_type,
|
|
70
|
+
"audio_start": @audio_start,
|
|
71
|
+
"audio_end": @audio_end,
|
|
72
|
+
"confidence": @confidence,
|
|
73
|
+
"text": @text,
|
|
74
|
+
"words": @words,
|
|
75
|
+
"created": @created
|
|
76
|
+
}.to_json
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# 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.
|
|
80
|
+
#
|
|
81
|
+
# @param obj [Object]
|
|
82
|
+
# @return [Void]
|
|
83
|
+
def self.validate_raw(obj:)
|
|
84
|
+
obj.message_type.is_a?(String) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
|
|
85
|
+
obj.audio_start.is_a?(Integer) != false || raise("Passed value for field obj.audio_start is not the expected type, validation failed.")
|
|
86
|
+
obj.audio_end.is_a?(Integer) != false || raise("Passed value for field obj.audio_end is not the expected type, validation failed.")
|
|
87
|
+
obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
|
|
88
|
+
obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
|
|
89
|
+
obj.words.is_a?(Array) != false || raise("Passed value for field obj.words is not the expected type, validation failed.")
|
|
90
|
+
obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "message_type"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module AssemblyAI
|
|
7
|
+
class Realtime
|
|
8
|
+
class RealtimeBaseMessage
|
|
9
|
+
attr_reader :message_type, :additional_properties
|
|
10
|
+
|
|
11
|
+
# @param message_type [MESSAGE_TYPE] Describes the type of the message
|
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
13
|
+
# @return [Realtime::RealtimeBaseMessage]
|
|
14
|
+
def initialize(message_type:, additional_properties: nil)
|
|
15
|
+
# @type [MESSAGE_TYPE] Describes the type of the message
|
|
16
|
+
@message_type = message_type
|
|
17
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
18
|
+
@additional_properties = additional_properties
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Deserialize a JSON object to an instance of RealtimeBaseMessage
|
|
22
|
+
#
|
|
23
|
+
# @param json_object [JSON]
|
|
24
|
+
# @return [Realtime::RealtimeBaseMessage]
|
|
25
|
+
def self.from_json(json_object:)
|
|
26
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
27
|
+
parsed_json = JSON.parse(json_object)
|
|
28
|
+
message_type = Realtime::MESSAGE_TYPE.key(parsed_json["message_type"]) || parsed_json["message_type"]
|
|
29
|
+
new(message_type: message_type, additional_properties: struct)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Serialize an instance of RealtimeBaseMessage to a JSON object
|
|
33
|
+
#
|
|
34
|
+
# @return [JSON]
|
|
35
|
+
def to_json(*_args)
|
|
36
|
+
{ "message_type": Realtime::MESSAGE_TYPE[@message_type] || @message_type }.to_json
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# 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.
|
|
40
|
+
#
|
|
41
|
+
# @param obj [Object]
|
|
42
|
+
# @return [Void]
|
|
43
|
+
def self.validate_raw(obj:)
|
|
44
|
+
obj.message_type.is_a?(Realtime::MESSAGE_TYPE) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "word"
|
|
4
|
+
require "date"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module AssemblyAI
|
|
8
|
+
class Realtime
|
|
9
|
+
class RealtimeBaseTranscript
|
|
10
|
+
attr_reader :audio_start, :audio_end, :confidence, :text, :words, :created, :additional_properties
|
|
11
|
+
|
|
12
|
+
# @param audio_start [Integer] Start time of audio sample relative to session start, in milliseconds
|
|
13
|
+
# @param audio_end [Integer] End time of audio sample relative to session start, in milliseconds
|
|
14
|
+
# @param confidence [Float] The confidence score of the entire transcription, between 0 and 1
|
|
15
|
+
# @param text [String] The partial transcript for your audio
|
|
16
|
+
# @param words [Array<Realtime::Word>] An array of objects, with the information for each word in the transcription text.
|
|
17
|
+
# Includes the start and end time of the word in milliseconds, the confidence score of the word, and the text, which is the word itself.
|
|
18
|
+
# @param created [DateTime] The timestamp for the partial transcript
|
|
19
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
20
|
+
# @return [Realtime::RealtimeBaseTranscript]
|
|
21
|
+
def initialize(audio_start:, audio_end:, confidence:, text:, words:, created:, additional_properties: nil)
|
|
22
|
+
# @type [Integer] Start time of audio sample relative to session start, in milliseconds
|
|
23
|
+
@audio_start = audio_start
|
|
24
|
+
# @type [Integer] End time of audio sample relative to session start, in milliseconds
|
|
25
|
+
@audio_end = audio_end
|
|
26
|
+
# @type [Float] The confidence score of the entire transcription, between 0 and 1
|
|
27
|
+
@confidence = confidence
|
|
28
|
+
# @type [String] The partial transcript for your audio
|
|
29
|
+
@text = text
|
|
30
|
+
# @type [Array<Realtime::Word>] An array of objects, with the information for each word in the transcription text.
|
|
31
|
+
# Includes the start and end time of the word in milliseconds, the confidence score of the word, and the text, which is the word itself.
|
|
32
|
+
@words = words
|
|
33
|
+
# @type [DateTime] The timestamp for the partial transcript
|
|
34
|
+
@created = created
|
|
35
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
36
|
+
@additional_properties = additional_properties
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Deserialize a JSON object to an instance of RealtimeBaseTranscript
|
|
40
|
+
#
|
|
41
|
+
# @param json_object [JSON]
|
|
42
|
+
# @return [Realtime::RealtimeBaseTranscript]
|
|
43
|
+
def self.from_json(json_object:)
|
|
44
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
45
|
+
parsed_json = JSON.parse(json_object)
|
|
46
|
+
audio_start = struct.audio_start
|
|
47
|
+
audio_end = struct.audio_end
|
|
48
|
+
confidence = struct.confidence
|
|
49
|
+
text = struct.text
|
|
50
|
+
words = parsed_json["words"]&.map do |v|
|
|
51
|
+
v = v.to_json
|
|
52
|
+
Realtime::Word.from_json(json_object: v)
|
|
53
|
+
end
|
|
54
|
+
created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
|
|
55
|
+
new(audio_start: audio_start, audio_end: audio_end, confidence: confidence, text: text, words: words,
|
|
56
|
+
created: created, additional_properties: struct)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Serialize an instance of RealtimeBaseTranscript to a JSON object
|
|
60
|
+
#
|
|
61
|
+
# @return [JSON]
|
|
62
|
+
def to_json(*_args)
|
|
63
|
+
{
|
|
64
|
+
"audio_start": @audio_start,
|
|
65
|
+
"audio_end": @audio_end,
|
|
66
|
+
"confidence": @confidence,
|
|
67
|
+
"text": @text,
|
|
68
|
+
"words": @words,
|
|
69
|
+
"created": @created
|
|
70
|
+
}.to_json
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# 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.
|
|
74
|
+
#
|
|
75
|
+
# @param obj [Object]
|
|
76
|
+
# @return [Void]
|
|
77
|
+
def self.validate_raw(obj:)
|
|
78
|
+
obj.audio_start.is_a?(Integer) != false || raise("Passed value for field obj.audio_start is not the expected type, validation failed.")
|
|
79
|
+
obj.audio_end.is_a?(Integer) != false || raise("Passed value for field obj.audio_end is not the expected type, validation failed.")
|
|
80
|
+
obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
|
|
81
|
+
obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
|
|
82
|
+
obj.words.is_a?(Array) != false || raise("Passed value for field obj.words is not the expected type, validation failed.")
|
|
83
|
+
obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Realtime
|
|
7
|
+
class RealtimeError
|
|
8
|
+
attr_reader :error, :additional_properties
|
|
9
|
+
|
|
10
|
+
# @param error [String]
|
|
11
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
12
|
+
# @return [Realtime::RealtimeError]
|
|
13
|
+
def initialize(error:, additional_properties: nil)
|
|
14
|
+
# @type [String]
|
|
15
|
+
@error = error
|
|
16
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
17
|
+
@additional_properties = additional_properties
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Deserialize a JSON object to an instance of RealtimeError
|
|
21
|
+
#
|
|
22
|
+
# @param json_object [JSON]
|
|
23
|
+
# @return [Realtime::RealtimeError]
|
|
24
|
+
def self.from_json(json_object:)
|
|
25
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
26
|
+
JSON.parse(json_object)
|
|
27
|
+
error = struct.error
|
|
28
|
+
new(error: error, additional_properties: struct)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Serialize an instance of RealtimeError to a JSON object
|
|
32
|
+
#
|
|
33
|
+
# @return [JSON]
|
|
34
|
+
def to_json(*_args)
|
|
35
|
+
{ "error": @error }.to_json
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# 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.
|
|
39
|
+
#
|
|
40
|
+
# @param obj [Object]
|
|
41
|
+
# @return [Void]
|
|
42
|
+
def self.validate_raw(obj:)
|
|
43
|
+
obj.error.is_a?(String) != false || raise("Passed value for field obj.error is not the expected type, validation failed.")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require_relative "session_begins"
|
|
5
|
+
require_relative "partial_transcript"
|
|
6
|
+
require_relative "final_transcript"
|
|
7
|
+
require_relative "session_terminated"
|
|
8
|
+
require_relative "realtime_error"
|
|
9
|
+
|
|
10
|
+
module AssemblyAI
|
|
11
|
+
class Realtime
|
|
12
|
+
class RealtimeMessage
|
|
13
|
+
attr_reader :member
|
|
14
|
+
alias kind_of? is_a?
|
|
15
|
+
# @param member [Object]
|
|
16
|
+
# @return [Realtime::RealtimeMessage]
|
|
17
|
+
def initialize(member:)
|
|
18
|
+
# @type [Object]
|
|
19
|
+
@member = member
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Deserialize a JSON object to an instance of RealtimeMessage
|
|
23
|
+
#
|
|
24
|
+
# @param json_object [JSON]
|
|
25
|
+
# @return [Realtime::RealtimeMessage]
|
|
26
|
+
def self.from_json(json_object:)
|
|
27
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
28
|
+
begin
|
|
29
|
+
Realtime::SessionBegins.validate_raw(obj: struct)
|
|
30
|
+
member = Realtime::SessionBegins.from_json(json_object: json_object)
|
|
31
|
+
return new(member: member)
|
|
32
|
+
rescue StandardError
|
|
33
|
+
# noop
|
|
34
|
+
end
|
|
35
|
+
begin
|
|
36
|
+
Realtime::PartialTranscript.validate_raw(obj: struct)
|
|
37
|
+
member = Realtime::PartialTranscript.from_json(json_object: json_object)
|
|
38
|
+
return new(member: member)
|
|
39
|
+
rescue StandardError
|
|
40
|
+
# noop
|
|
41
|
+
end
|
|
42
|
+
begin
|
|
43
|
+
Realtime::FinalTranscript.validate_raw(obj: struct)
|
|
44
|
+
member = Realtime::FinalTranscript.from_json(json_object: json_object)
|
|
45
|
+
return new(member: member)
|
|
46
|
+
rescue StandardError
|
|
47
|
+
# noop
|
|
48
|
+
end
|
|
49
|
+
begin
|
|
50
|
+
Realtime::SessionTerminated.validate_raw(obj: struct)
|
|
51
|
+
member = Realtime::SessionTerminated.from_json(json_object: json_object)
|
|
52
|
+
return new(member: member)
|
|
53
|
+
rescue StandardError
|
|
54
|
+
# noop
|
|
55
|
+
end
|
|
56
|
+
begin
|
|
57
|
+
Realtime::RealtimeError.validate_raw(obj: struct)
|
|
58
|
+
member = Realtime::RealtimeError.from_json(json_object: json_object)
|
|
59
|
+
return new(member: member)
|
|
60
|
+
rescue StandardError
|
|
61
|
+
# noop
|
|
62
|
+
end
|
|
63
|
+
new(member: struct)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# For Union Types, to_json functionality is delegated to the wrapped member.
|
|
67
|
+
#
|
|
68
|
+
# @return [JSON]
|
|
69
|
+
def to_json(*_args)
|
|
70
|
+
@member.to_json
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# 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.
|
|
74
|
+
#
|
|
75
|
+
# @param obj [Object]
|
|
76
|
+
# @return [Void]
|
|
77
|
+
def self.validate_raw(obj:)
|
|
78
|
+
begin
|
|
79
|
+
return Realtime::SessionBegins.validate_raw(obj: obj)
|
|
80
|
+
rescue StandardError
|
|
81
|
+
# noop
|
|
82
|
+
end
|
|
83
|
+
begin
|
|
84
|
+
return Realtime::PartialTranscript.validate_raw(obj: obj)
|
|
85
|
+
rescue StandardError
|
|
86
|
+
# noop
|
|
87
|
+
end
|
|
88
|
+
begin
|
|
89
|
+
return Realtime::FinalTranscript.validate_raw(obj: obj)
|
|
90
|
+
rescue StandardError
|
|
91
|
+
# noop
|
|
92
|
+
end
|
|
93
|
+
begin
|
|
94
|
+
return Realtime::SessionTerminated.validate_raw(obj: obj)
|
|
95
|
+
rescue StandardError
|
|
96
|
+
# noop
|
|
97
|
+
end
|
|
98
|
+
begin
|
|
99
|
+
return Realtime::RealtimeError.validate_raw(obj: obj)
|
|
100
|
+
rescue StandardError
|
|
101
|
+
# noop
|
|
102
|
+
end
|
|
103
|
+
raise("Passed value matched no type within the union, validation failed.")
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# For Union Types, is_a? functionality is delegated to the wrapped member.
|
|
107
|
+
#
|
|
108
|
+
# @param obj [Object]
|
|
109
|
+
# @return [Boolean]
|
|
110
|
+
def is_a?(obj)
|
|
111
|
+
@member.is_a?(obj)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Realtime
|
|
7
|
+
class RealtimeTemporaryTokenResponse
|
|
8
|
+
attr_reader :token, :additional_properties
|
|
9
|
+
|
|
10
|
+
# @param token [String] The temporary authentication token for real-time transcription
|
|
11
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
12
|
+
# @return [Realtime::RealtimeTemporaryTokenResponse]
|
|
13
|
+
def initialize(token:, additional_properties: nil)
|
|
14
|
+
# @type [String] The temporary authentication token for real-time transcription
|
|
15
|
+
@token = token
|
|
16
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
17
|
+
@additional_properties = additional_properties
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Deserialize a JSON object to an instance of RealtimeTemporaryTokenResponse
|
|
21
|
+
#
|
|
22
|
+
# @param json_object [JSON]
|
|
23
|
+
# @return [Realtime::RealtimeTemporaryTokenResponse]
|
|
24
|
+
def self.from_json(json_object:)
|
|
25
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
26
|
+
JSON.parse(json_object)
|
|
27
|
+
token = struct.token
|
|
28
|
+
new(token: token, additional_properties: struct)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Serialize an instance of RealtimeTemporaryTokenResponse to a JSON object
|
|
32
|
+
#
|
|
33
|
+
# @return [JSON]
|
|
34
|
+
def to_json(*_args)
|
|
35
|
+
{ "token": @token }.to_json
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# 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.
|
|
39
|
+
#
|
|
40
|
+
# @param obj [Object]
|
|
41
|
+
# @return [Void]
|
|
42
|
+
def self.validate_raw(obj:)
|
|
43
|
+
obj.token.is_a?(String) != false || raise("Passed value for field obj.token is not the expected type, validation failed.")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require_relative "partial_transcript"
|
|
5
|
+
require_relative "final_transcript"
|
|
6
|
+
|
|
7
|
+
module AssemblyAI
|
|
8
|
+
class Realtime
|
|
9
|
+
class RealtimeTranscript
|
|
10
|
+
attr_reader :member
|
|
11
|
+
alias kind_of? is_a?
|
|
12
|
+
# @param member [Object]
|
|
13
|
+
# @return [Realtime::RealtimeTranscript]
|
|
14
|
+
def initialize(member:)
|
|
15
|
+
# @type [Object]
|
|
16
|
+
@member = member
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Deserialize a JSON object to an instance of RealtimeTranscript
|
|
20
|
+
#
|
|
21
|
+
# @param json_object [JSON]
|
|
22
|
+
# @return [Realtime::RealtimeTranscript]
|
|
23
|
+
def self.from_json(json_object:)
|
|
24
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
25
|
+
begin
|
|
26
|
+
Realtime::PartialTranscript.validate_raw(obj: struct)
|
|
27
|
+
member = Realtime::PartialTranscript.from_json(json_object: json_object)
|
|
28
|
+
return new(member: member)
|
|
29
|
+
rescue StandardError
|
|
30
|
+
# noop
|
|
31
|
+
end
|
|
32
|
+
begin
|
|
33
|
+
Realtime::FinalTranscript.validate_raw(obj: struct)
|
|
34
|
+
member = Realtime::FinalTranscript.from_json(json_object: json_object)
|
|
35
|
+
return new(member: member)
|
|
36
|
+
rescue StandardError
|
|
37
|
+
# noop
|
|
38
|
+
end
|
|
39
|
+
new(member: struct)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# For Union Types, to_json functionality is delegated to the wrapped member.
|
|
43
|
+
#
|
|
44
|
+
# @return [JSON]
|
|
45
|
+
def to_json(*_args)
|
|
46
|
+
@member.to_json
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# 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.
|
|
50
|
+
#
|
|
51
|
+
# @param obj [Object]
|
|
52
|
+
# @return [Void]
|
|
53
|
+
def self.validate_raw(obj:)
|
|
54
|
+
begin
|
|
55
|
+
return Realtime::PartialTranscript.validate_raw(obj: obj)
|
|
56
|
+
rescue StandardError
|
|
57
|
+
# noop
|
|
58
|
+
end
|
|
59
|
+
begin
|
|
60
|
+
return Realtime::FinalTranscript.validate_raw(obj: obj)
|
|
61
|
+
rescue StandardError
|
|
62
|
+
# noop
|
|
63
|
+
end
|
|
64
|
+
raise("Passed value matched no type within the union, validation failed.")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# For Union Types, is_a? functionality is delegated to the wrapped member.
|
|
68
|
+
#
|
|
69
|
+
# @param obj [Object]
|
|
70
|
+
# @return [Boolean]
|
|
71
|
+
def is_a?(obj)
|
|
72
|
+
@member.is_a?(obj)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|