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,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "entity_type"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module AssemblyAI
|
|
7
|
+
class Transcripts
|
|
8
|
+
# A detected entity
|
|
9
|
+
class Entity
|
|
10
|
+
attr_reader :entity_type, :text, :start, :end_, :additional_properties
|
|
11
|
+
|
|
12
|
+
# @param entity_type [ENTITY_TYPE] The type of entity for the detected entity
|
|
13
|
+
# @param text [String] The text for the detected entity
|
|
14
|
+
# @param start [Integer] The starting time, in milliseconds, at which the detected entity appears in the audio file
|
|
15
|
+
# @param end_ [Integer] The ending time, in milliseconds, for the detected entity in the audio file
|
|
16
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
17
|
+
# @return [Transcripts::Entity]
|
|
18
|
+
def initialize(entity_type:, text:, start:, end_:, additional_properties: nil)
|
|
19
|
+
# @type [ENTITY_TYPE] The type of entity for the detected entity
|
|
20
|
+
@entity_type = entity_type
|
|
21
|
+
# @type [String] The text for the detected entity
|
|
22
|
+
@text = text
|
|
23
|
+
# @type [Integer] The starting time, in milliseconds, at which the detected entity appears in the audio file
|
|
24
|
+
@start = start
|
|
25
|
+
# @type [Integer] The ending time, in milliseconds, for the detected entity in the audio file
|
|
26
|
+
@end_ = end_
|
|
27
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
28
|
+
@additional_properties = additional_properties
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Deserialize a JSON object to an instance of Entity
|
|
32
|
+
#
|
|
33
|
+
# @param json_object [JSON]
|
|
34
|
+
# @return [Transcripts::Entity]
|
|
35
|
+
def self.from_json(json_object:)
|
|
36
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
37
|
+
parsed_json = JSON.parse(json_object)
|
|
38
|
+
entity_type = Transcripts::ENTITY_TYPE.key(parsed_json["entity_type"]) || parsed_json["entity_type"]
|
|
39
|
+
text = struct.text
|
|
40
|
+
start = struct.start
|
|
41
|
+
end_ = struct.end
|
|
42
|
+
new(entity_type: entity_type, text: text, start: start, end_: end_, additional_properties: struct)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Serialize an instance of Entity to a JSON object
|
|
46
|
+
#
|
|
47
|
+
# @return [JSON]
|
|
48
|
+
def to_json(*_args)
|
|
49
|
+
{
|
|
50
|
+
"entity_type": Transcripts::ENTITY_TYPE[@entity_type] || @entity_type,
|
|
51
|
+
"text": @text,
|
|
52
|
+
"start": @start,
|
|
53
|
+
"end": @end_
|
|
54
|
+
}.to_json
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# 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.
|
|
58
|
+
#
|
|
59
|
+
# @param obj [Object]
|
|
60
|
+
# @return [Void]
|
|
61
|
+
def self.validate_raw(obj:)
|
|
62
|
+
obj.entity_type.is_a?(Transcripts::ENTITY_TYPE) != false || raise("Passed value for field obj.entity_type is not the expected type, validation failed.")
|
|
63
|
+
obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
|
|
64
|
+
obj.start.is_a?(Integer) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
|
65
|
+
obj.end_.is_a?(Integer) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AssemblyAI
|
|
4
|
+
class Transcripts
|
|
5
|
+
# @type [ENTITY_TYPE]
|
|
6
|
+
ENTITY_TYPE = {
|
|
7
|
+
banking_information: "banking_information",
|
|
8
|
+
blood_type: "blood_type",
|
|
9
|
+
credit_card_cvv: "credit_card_cvv",
|
|
10
|
+
credit_card_expiration: "credit_card_expiration",
|
|
11
|
+
credit_card_number: "credit_card_number",
|
|
12
|
+
date: "date",
|
|
13
|
+
date_of_birth: "date_of_birth",
|
|
14
|
+
drivers_license: "drivers_license",
|
|
15
|
+
drug: "drug",
|
|
16
|
+
email_address: "email_address",
|
|
17
|
+
event: "event",
|
|
18
|
+
injury: "injury",
|
|
19
|
+
language: "language",
|
|
20
|
+
location: "location",
|
|
21
|
+
medical_condition: "medical_condition",
|
|
22
|
+
medical_process: "medical_process",
|
|
23
|
+
money_amount: "money_amount",
|
|
24
|
+
nationality: "nationality",
|
|
25
|
+
occupation: "occupation",
|
|
26
|
+
organization: "organization",
|
|
27
|
+
password: "password",
|
|
28
|
+
person_age: "person_age",
|
|
29
|
+
person_name: "person_name",
|
|
30
|
+
phone_number: "phone_number",
|
|
31
|
+
political_affiliation: "political_affiliation",
|
|
32
|
+
religion: "religion",
|
|
33
|
+
time: "time",
|
|
34
|
+
url: "url",
|
|
35
|
+
us_social_security_number: "us_social_security_number"
|
|
36
|
+
}.freeze
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Transcripts
|
|
7
|
+
class PageDetails
|
|
8
|
+
attr_reader :limit, :result_count, :current_url, :prev_url, :next_url, :additional_properties
|
|
9
|
+
|
|
10
|
+
# @param limit [Integer]
|
|
11
|
+
# @param result_count [Integer]
|
|
12
|
+
# @param current_url [String]
|
|
13
|
+
# @param prev_url [String]
|
|
14
|
+
# @param next_url [String]
|
|
15
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
16
|
+
# @return [Transcripts::PageDetails]
|
|
17
|
+
def initialize(limit:, result_count:, current_url:, prev_url:, next_url: nil, additional_properties: nil)
|
|
18
|
+
# @type [Integer]
|
|
19
|
+
@limit = limit
|
|
20
|
+
# @type [Integer]
|
|
21
|
+
@result_count = result_count
|
|
22
|
+
# @type [String]
|
|
23
|
+
@current_url = current_url
|
|
24
|
+
# @type [String]
|
|
25
|
+
@prev_url = prev_url
|
|
26
|
+
# @type [String]
|
|
27
|
+
@next_url = next_url
|
|
28
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
29
|
+
@additional_properties = additional_properties
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Deserialize a JSON object to an instance of PageDetails
|
|
33
|
+
#
|
|
34
|
+
# @param json_object [JSON]
|
|
35
|
+
# @return [Transcripts::PageDetails]
|
|
36
|
+
def self.from_json(json_object:)
|
|
37
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
38
|
+
JSON.parse(json_object)
|
|
39
|
+
limit = struct.limit
|
|
40
|
+
result_count = struct.result_count
|
|
41
|
+
current_url = struct.current_url
|
|
42
|
+
prev_url = struct.prev_url
|
|
43
|
+
next_url = struct.next_url
|
|
44
|
+
new(limit: limit, result_count: result_count, current_url: current_url, prev_url: prev_url, next_url: next_url,
|
|
45
|
+
additional_properties: struct)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Serialize an instance of PageDetails to a JSON object
|
|
49
|
+
#
|
|
50
|
+
# @return [JSON]
|
|
51
|
+
def to_json(*_args)
|
|
52
|
+
{
|
|
53
|
+
"limit": @limit,
|
|
54
|
+
"result_count": @result_count,
|
|
55
|
+
"current_url": @current_url,
|
|
56
|
+
"prev_url": @prev_url,
|
|
57
|
+
"next_url": @next_url
|
|
58
|
+
}.to_json
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# 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.
|
|
62
|
+
#
|
|
63
|
+
# @param obj [Object]
|
|
64
|
+
# @return [Void]
|
|
65
|
+
def self.validate_raw(obj:)
|
|
66
|
+
obj.limit.is_a?(Integer) != false || raise("Passed value for field obj.limit is not the expected type, validation failed.")
|
|
67
|
+
obj.result_count.is_a?(Integer) != false || raise("Passed value for field obj.result_count is not the expected type, validation failed.")
|
|
68
|
+
obj.current_url.is_a?(String) != false || raise("Passed value for field obj.current_url is not the expected type, validation failed.")
|
|
69
|
+
obj.prev_url.is_a?(String) != false || raise("Passed value for field obj.prev_url is not the expected type, validation failed.")
|
|
70
|
+
obj.next_url&.is_a?(String) != false || raise("Passed value for field obj.next_url is not the expected type, validation failed.")
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "transcript_paragraph"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module AssemblyAI
|
|
7
|
+
class Transcripts
|
|
8
|
+
class ParagraphsResponse
|
|
9
|
+
attr_reader :id, :confidence, :audio_duration, :paragraphs, :additional_properties
|
|
10
|
+
|
|
11
|
+
# @param id [String]
|
|
12
|
+
# @param confidence [Float]
|
|
13
|
+
# @param audio_duration [Float]
|
|
14
|
+
# @param paragraphs [Array<Transcripts::TranscriptParagraph>]
|
|
15
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
16
|
+
# @return [Transcripts::ParagraphsResponse]
|
|
17
|
+
def initialize(id:, confidence:, audio_duration:, paragraphs:, additional_properties: nil)
|
|
18
|
+
# @type [String]
|
|
19
|
+
@id = id
|
|
20
|
+
# @type [Float]
|
|
21
|
+
@confidence = confidence
|
|
22
|
+
# @type [Float]
|
|
23
|
+
@audio_duration = audio_duration
|
|
24
|
+
# @type [Array<Transcripts::TranscriptParagraph>]
|
|
25
|
+
@paragraphs = paragraphs
|
|
26
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
27
|
+
@additional_properties = additional_properties
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Deserialize a JSON object to an instance of ParagraphsResponse
|
|
31
|
+
#
|
|
32
|
+
# @param json_object [JSON]
|
|
33
|
+
# @return [Transcripts::ParagraphsResponse]
|
|
34
|
+
def self.from_json(json_object:)
|
|
35
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
36
|
+
parsed_json = JSON.parse(json_object)
|
|
37
|
+
id = struct.id
|
|
38
|
+
confidence = struct.confidence
|
|
39
|
+
audio_duration = struct.audio_duration
|
|
40
|
+
paragraphs = parsed_json["paragraphs"]&.map do |v|
|
|
41
|
+
v = v.to_json
|
|
42
|
+
Transcripts::TranscriptParagraph.from_json(json_object: v)
|
|
43
|
+
end
|
|
44
|
+
new(id: id, confidence: confidence, audio_duration: audio_duration, paragraphs: paragraphs,
|
|
45
|
+
additional_properties: struct)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Serialize an instance of ParagraphsResponse to a JSON object
|
|
49
|
+
#
|
|
50
|
+
# @return [JSON]
|
|
51
|
+
def to_json(*_args)
|
|
52
|
+
{ "id": @id, "confidence": @confidence, "audio_duration": @audio_duration, "paragraphs": @paragraphs }.to_json
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# 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.
|
|
56
|
+
#
|
|
57
|
+
# @param obj [Object]
|
|
58
|
+
# @return [Void]
|
|
59
|
+
def self.validate_raw(obj:)
|
|
60
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
61
|
+
obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
|
|
62
|
+
obj.audio_duration.is_a?(Float) != false || raise("Passed value for field obj.audio_duration is not the expected type, validation failed.")
|
|
63
|
+
obj.paragraphs.is_a?(Array) != false || raise("Passed value for field obj.paragraphs is not the expected type, validation failed.")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AssemblyAI
|
|
4
|
+
class Transcripts
|
|
5
|
+
# @type [PII_POLICY]
|
|
6
|
+
PII_POLICY = {
|
|
7
|
+
medical_process: "medical_process",
|
|
8
|
+
medical_condition: "medical_condition",
|
|
9
|
+
blood_type: "blood_type",
|
|
10
|
+
drug: "drug",
|
|
11
|
+
injury: "injury",
|
|
12
|
+
number_sequence: "number_sequence",
|
|
13
|
+
email_address: "email_address",
|
|
14
|
+
date_of_birth: "date_of_birth",
|
|
15
|
+
phone_number: "phone_number",
|
|
16
|
+
us_social_security_number: "us_social_security_number",
|
|
17
|
+
credit_card_number: "credit_card_number",
|
|
18
|
+
credit_card_expiration: "credit_card_expiration",
|
|
19
|
+
credit_card_cvv: "credit_card_cvv",
|
|
20
|
+
date: "date",
|
|
21
|
+
nationality: "nationality",
|
|
22
|
+
event: "event",
|
|
23
|
+
language: "language",
|
|
24
|
+
location: "location",
|
|
25
|
+
money_amount: "money_amount",
|
|
26
|
+
person_name: "person_name",
|
|
27
|
+
person_age: "person_age",
|
|
28
|
+
organization: "organization",
|
|
29
|
+
political_affiliation: "political_affiliation",
|
|
30
|
+
occupation: "occupation",
|
|
31
|
+
religion: "religion",
|
|
32
|
+
drivers_license: "drivers_license",
|
|
33
|
+
banking_information: "banking_information"
|
|
34
|
+
}.freeze
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AssemblyAI
|
|
4
|
+
class Transcripts
|
|
5
|
+
# Configuration options for polling requests.
|
|
6
|
+
class PollingOptions
|
|
7
|
+
attr_reader :interval, :timeout
|
|
8
|
+
|
|
9
|
+
# @param interval [Integer] The amount of time to wait between polling requests, in milliseconds. Defaults to 3000.
|
|
10
|
+
# @param timeout [Integer] The maximum amount of time to wait for the transcript to be ready, in milliseconds. Defaults to -1, which means poll forever.
|
|
11
|
+
# @return [Transcripts::PollingOptions]
|
|
12
|
+
def initialize(interval: 3000, timeout: -1)
|
|
13
|
+
# @type [Integer] The amount of time to wait between polling requests, in milliseconds.
|
|
14
|
+
@interval = interval
|
|
15
|
+
# @type [Integer] The maximum amount of time to wait for the transcript to be ready, in milliseconds.
|
|
16
|
+
@timeout = timeout
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "redacted_audio_status"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module AssemblyAI
|
|
7
|
+
class Transcripts
|
|
8
|
+
class RedactedAudioResponse
|
|
9
|
+
attr_reader :status, :redacted_audio_url, :additional_properties
|
|
10
|
+
|
|
11
|
+
# @param status [Transcripts::REDACTED_AUDIO_STATUS] The status of the redacted audio
|
|
12
|
+
# @param redacted_audio_url [String] The URL of the redacted audio file
|
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
14
|
+
# @return [Transcripts::RedactedAudioResponse]
|
|
15
|
+
def initialize(status:, redacted_audio_url:, additional_properties: nil)
|
|
16
|
+
# @type [Transcripts::REDACTED_AUDIO_STATUS] The status of the redacted audio
|
|
17
|
+
@status = status
|
|
18
|
+
# @type [String] The URL of the redacted audio file
|
|
19
|
+
@redacted_audio_url = redacted_audio_url
|
|
20
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
21
|
+
@additional_properties = additional_properties
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Deserialize a JSON object to an instance of RedactedAudioResponse
|
|
25
|
+
#
|
|
26
|
+
# @param json_object [JSON]
|
|
27
|
+
# @return [Transcripts::RedactedAudioResponse]
|
|
28
|
+
def self.from_json(json_object:)
|
|
29
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
30
|
+
JSON.parse(json_object)
|
|
31
|
+
status = struct.status
|
|
32
|
+
redacted_audio_url = struct.redacted_audio_url
|
|
33
|
+
new(status: status, redacted_audio_url: redacted_audio_url, additional_properties: struct)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Serialize an instance of RedactedAudioResponse to a JSON object
|
|
37
|
+
#
|
|
38
|
+
# @return [JSON]
|
|
39
|
+
def to_json(*_args)
|
|
40
|
+
{ "status": @status, "redacted_audio_url": @redacted_audio_url }.to_json
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# 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.
|
|
44
|
+
#
|
|
45
|
+
# @param obj [Object]
|
|
46
|
+
# @return [Void]
|
|
47
|
+
def self.validate_raw(obj:)
|
|
48
|
+
obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
|
49
|
+
obj.redacted_audio_url.is_a?(String) != false || raise("Passed value for field obj.redacted_audio_url is not the expected type, validation failed.")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "transcript_sentence"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module AssemblyAI
|
|
7
|
+
class Transcripts
|
|
8
|
+
class SentencesResponse
|
|
9
|
+
attr_reader :id, :confidence, :audio_duration, :sentences, :additional_properties
|
|
10
|
+
|
|
11
|
+
# @param id [String]
|
|
12
|
+
# @param confidence [Float]
|
|
13
|
+
# @param audio_duration [Float]
|
|
14
|
+
# @param sentences [Array<Transcripts::TranscriptSentence>]
|
|
15
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
16
|
+
# @return [Transcripts::SentencesResponse]
|
|
17
|
+
def initialize(id:, confidence:, audio_duration:, sentences:, additional_properties: nil)
|
|
18
|
+
# @type [String]
|
|
19
|
+
@id = id
|
|
20
|
+
# @type [Float]
|
|
21
|
+
@confidence = confidence
|
|
22
|
+
# @type [Float]
|
|
23
|
+
@audio_duration = audio_duration
|
|
24
|
+
# @type [Array<Transcripts::TranscriptSentence>]
|
|
25
|
+
@sentences = sentences
|
|
26
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
27
|
+
@additional_properties = additional_properties
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Deserialize a JSON object to an instance of SentencesResponse
|
|
31
|
+
#
|
|
32
|
+
# @param json_object [JSON]
|
|
33
|
+
# @return [Transcripts::SentencesResponse]
|
|
34
|
+
def self.from_json(json_object:)
|
|
35
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
36
|
+
parsed_json = JSON.parse(json_object)
|
|
37
|
+
id = struct.id
|
|
38
|
+
confidence = struct.confidence
|
|
39
|
+
audio_duration = struct.audio_duration
|
|
40
|
+
sentences = parsed_json["sentences"]&.map do |v|
|
|
41
|
+
v = v.to_json
|
|
42
|
+
Transcripts::TranscriptSentence.from_json(json_object: v)
|
|
43
|
+
end
|
|
44
|
+
new(id: id, confidence: confidence, audio_duration: audio_duration, sentences: sentences,
|
|
45
|
+
additional_properties: struct)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Serialize an instance of SentencesResponse to a JSON object
|
|
49
|
+
#
|
|
50
|
+
# @return [JSON]
|
|
51
|
+
def to_json(*_args)
|
|
52
|
+
{ "id": @id, "confidence": @confidence, "audio_duration": @audio_duration, "sentences": @sentences }.to_json
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# 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.
|
|
56
|
+
#
|
|
57
|
+
# @param obj [Object]
|
|
58
|
+
# @return [Void]
|
|
59
|
+
def self.validate_raw(obj:)
|
|
60
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
61
|
+
obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
|
|
62
|
+
obj.audio_duration.is_a?(Float) != false || raise("Passed value for field obj.audio_duration is not the expected type, validation failed.")
|
|
63
|
+
obj.sentences.is_a?(Array) != false || raise("Passed value for field obj.sentences is not the expected type, validation failed.")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "sentiment"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module AssemblyAI
|
|
7
|
+
class Transcripts
|
|
8
|
+
# The result of the sentiment analysis model
|
|
9
|
+
class SentimentAnalysisResult
|
|
10
|
+
attr_reader :text, :start, :end_, :sentiment, :confidence, :speaker, :additional_properties
|
|
11
|
+
|
|
12
|
+
# @param text [String] The transcript of the sentence
|
|
13
|
+
# @param start [Integer] The starting time, in milliseconds, of the sentence
|
|
14
|
+
# @param end_ [Integer] The ending time, in milliseconds, of the sentence
|
|
15
|
+
# @param sentiment [SENTIMENT] The detected sentiment for the sentence, one of POSITIVE, NEUTRAL, NEGATIVE
|
|
16
|
+
# @param confidence [Float] The confidence score for the detected sentiment of the sentence, from 0 to 1
|
|
17
|
+
# @param speaker [String] The speaker of the sentence if [Speaker Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is enabled, else null
|
|
18
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
19
|
+
# @return [Transcripts::SentimentAnalysisResult]
|
|
20
|
+
def initialize(text:, start:, end_:, sentiment:, confidence:, speaker: nil, additional_properties: nil)
|
|
21
|
+
# @type [String] The transcript of the sentence
|
|
22
|
+
@text = text
|
|
23
|
+
# @type [Integer] The starting time, in milliseconds, of the sentence
|
|
24
|
+
@start = start
|
|
25
|
+
# @type [Integer] The ending time, in milliseconds, of the sentence
|
|
26
|
+
@end_ = end_
|
|
27
|
+
# @type [SENTIMENT] The detected sentiment for the sentence, one of POSITIVE, NEUTRAL, NEGATIVE
|
|
28
|
+
@sentiment = sentiment
|
|
29
|
+
# @type [Float] The confidence score for the detected sentiment of the sentence, from 0 to 1
|
|
30
|
+
@confidence = confidence
|
|
31
|
+
# @type [String] The speaker of the sentence if [Speaker Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is enabled, else null
|
|
32
|
+
@speaker = speaker
|
|
33
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
34
|
+
@additional_properties = additional_properties
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Deserialize a JSON object to an instance of SentimentAnalysisResult
|
|
38
|
+
#
|
|
39
|
+
# @param json_object [JSON]
|
|
40
|
+
# @return [Transcripts::SentimentAnalysisResult]
|
|
41
|
+
def self.from_json(json_object:)
|
|
42
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
43
|
+
parsed_json = JSON.parse(json_object)
|
|
44
|
+
text = struct.text
|
|
45
|
+
start = struct.start
|
|
46
|
+
end_ = struct.end
|
|
47
|
+
sentiment = Transcripts::SENTIMENT.key(parsed_json["sentiment"]) || parsed_json["sentiment"]
|
|
48
|
+
confidence = struct.confidence
|
|
49
|
+
speaker = struct.speaker
|
|
50
|
+
new(text: text, start: start, end_: end_, sentiment: sentiment, confidence: confidence, speaker: speaker,
|
|
51
|
+
additional_properties: struct)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Serialize an instance of SentimentAnalysisResult to a JSON object
|
|
55
|
+
#
|
|
56
|
+
# @return [JSON]
|
|
57
|
+
def to_json(*_args)
|
|
58
|
+
{
|
|
59
|
+
"text": @text,
|
|
60
|
+
"start": @start,
|
|
61
|
+
"end": @end_,
|
|
62
|
+
"sentiment": Transcripts::SENTIMENT[@sentiment] || @sentiment,
|
|
63
|
+
"confidence": @confidence,
|
|
64
|
+
"speaker": @speaker
|
|
65
|
+
}.to_json
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# 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.
|
|
69
|
+
#
|
|
70
|
+
# @param obj [Object]
|
|
71
|
+
# @return [Void]
|
|
72
|
+
def self.validate_raw(obj:)
|
|
73
|
+
obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
|
|
74
|
+
obj.start.is_a?(Integer) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
|
75
|
+
obj.end_.is_a?(Integer) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
|
76
|
+
obj.sentiment.is_a?(Transcripts::SENTIMENT) != false || raise("Passed value for field obj.sentiment is not the expected type, validation failed.")
|
|
77
|
+
obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
|
|
78
|
+
obj.speaker&.is_a?(String) != false || raise("Passed value for field obj.speaker is not the expected type, validation failed.")
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Transcripts
|
|
7
|
+
class SeverityScoreSummary
|
|
8
|
+
attr_reader :low, :medium, :high, :additional_properties
|
|
9
|
+
|
|
10
|
+
# @param low [Float]
|
|
11
|
+
# @param medium [Float]
|
|
12
|
+
# @param high [Float]
|
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
14
|
+
# @return [Transcripts::SeverityScoreSummary]
|
|
15
|
+
def initialize(low:, medium:, high:, additional_properties: nil)
|
|
16
|
+
# @type [Float]
|
|
17
|
+
@low = low
|
|
18
|
+
# @type [Float]
|
|
19
|
+
@medium = medium
|
|
20
|
+
# @type [Float]
|
|
21
|
+
@high = high
|
|
22
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
23
|
+
@additional_properties = additional_properties
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Deserialize a JSON object to an instance of SeverityScoreSummary
|
|
27
|
+
#
|
|
28
|
+
# @param json_object [JSON]
|
|
29
|
+
# @return [Transcripts::SeverityScoreSummary]
|
|
30
|
+
def self.from_json(json_object:)
|
|
31
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
32
|
+
JSON.parse(json_object)
|
|
33
|
+
low = struct.low
|
|
34
|
+
medium = struct.medium
|
|
35
|
+
high = struct.high
|
|
36
|
+
new(low: low, medium: medium, high: high, additional_properties: struct)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Serialize an instance of SeverityScoreSummary to a JSON object
|
|
40
|
+
#
|
|
41
|
+
# @return [JSON]
|
|
42
|
+
def to_json(*_args)
|
|
43
|
+
{ "low": @low, "medium": @medium, "high": @high }.to_json
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# 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.
|
|
47
|
+
#
|
|
48
|
+
# @param obj [Object]
|
|
49
|
+
# @return [Void]
|
|
50
|
+
def self.validate_raw(obj:)
|
|
51
|
+
obj.low.is_a?(Float) != false || raise("Passed value for field obj.low is not the expected type, validation failed.")
|
|
52
|
+
obj.medium.is_a?(Float) != false || raise("Passed value for field obj.medium is not the expected type, validation failed.")
|
|
53
|
+
obj.high.is_a?(Float) != false || raise("Passed value for field obj.high is not the expected type, validation failed.")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AssemblyAI
|
|
4
|
+
class Transcripts
|
|
5
|
+
# @type [SUMMARY_TYPE]
|
|
6
|
+
SUMMARY_TYPE = {
|
|
7
|
+
bullets: "bullets",
|
|
8
|
+
bullets_verbose: "bullets_verbose",
|
|
9
|
+
gist: "gist",
|
|
10
|
+
headline: "headline",
|
|
11
|
+
paragraph: "paragraph"
|
|
12
|
+
}.freeze
|
|
13
|
+
end
|
|
14
|
+
end
|