assemblyai 1.0.0.pre.beta.7 → 1.0.0.pre.beta.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/lib/assemblyai/files/client.rb +4 -2
  3. data/lib/assemblyai/files/types/uploaded_file.rb +20 -11
  4. data/lib/assemblyai/lemur/client.rb +256 -150
  5. data/lib/assemblyai/lemur/types/lemur_action_items_response.rb +28 -14
  6. data/lib/assemblyai/lemur/types/lemur_base_params.rb +83 -54
  7. data/lib/assemblyai/lemur/types/lemur_base_params_context.rb +11 -5
  8. data/lib/assemblyai/lemur/types/lemur_base_response.rb +20 -11
  9. data/lib/assemblyai/lemur/types/lemur_question.rb +57 -31
  10. data/lib/assemblyai/lemur/types/lemur_question_answer.rb +28 -14
  11. data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +29 -14
  12. data/lib/assemblyai/lemur/types/lemur_question_context.rb +13 -6
  13. data/lib/assemblyai/lemur/types/lemur_summary_response.rb +28 -14
  14. data/lib/assemblyai/lemur/types/lemur_task_response.rb +28 -14
  15. data/lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb +32 -17
  16. data/lib/assemblyai/realtime/client.rb +30 -14
  17. data/lib/assemblyai/realtime/types/configure_end_utterance_silence_threshold.rb +24 -13
  18. data/lib/assemblyai/realtime/types/final_transcript.rb +72 -41
  19. data/lib/assemblyai/realtime/types/force_end_utterance.rb +20 -11
  20. data/lib/assemblyai/realtime/types/message_type.rb +1 -0
  21. data/lib/assemblyai/realtime/types/partial_transcript.rb +62 -34
  22. data/lib/assemblyai/realtime/types/realtime_base_message.rb +22 -13
  23. data/lib/assemblyai/realtime/types/realtime_base_transcript.rb +57 -31
  24. data/lib/assemblyai/realtime/types/realtime_error.rb +20 -11
  25. data/lib/assemblyai/realtime/types/realtime_message.rb +44 -18
  26. data/lib/assemblyai/realtime/types/realtime_temporary_token_response.rb +20 -11
  27. data/lib/assemblyai/realtime/types/realtime_transcript.rb +15 -9
  28. data/lib/assemblyai/realtime/types/session_begins.rb +31 -14
  29. data/lib/assemblyai/realtime/types/session_information.rb +69 -0
  30. data/lib/assemblyai/realtime/types/session_terminated.rb +20 -11
  31. data/lib/assemblyai/realtime/types/terminate_session.rb +20 -11
  32. data/lib/assemblyai/realtime/types/word.rb +36 -18
  33. data/lib/assemblyai/streaming/types/receive_message.rb +113 -0
  34. data/lib/assemblyai/{realtime → streaming}/types/send_message.rb +26 -14
  35. data/lib/assemblyai/streaming/types/streaming.rb +11 -0
  36. data/lib/assemblyai/transcripts/client.rb +50 -18
  37. data/lib/assemblyai/transcripts/list_by_url_client.rb +6 -4
  38. data/lib/assemblyai/transcripts/polling_client.rb +12 -2
  39. data/lib/assemblyai/transcripts/types/auto_highlight_result.rb +40 -19
  40. data/lib/assemblyai/transcripts/types/auto_highlights_result.rb +38 -14
  41. data/lib/assemblyai/transcripts/types/chapter.rb +40 -20
  42. data/lib/assemblyai/transcripts/types/content_safety_label.rb +32 -16
  43. data/lib/assemblyai/transcripts/types/content_safety_label_result.rb +51 -29
  44. data/lib/assemblyai/transcripts/types/content_safety_labels_result.rb +51 -29
  45. data/lib/assemblyai/transcripts/types/entity.rb +41 -21
  46. data/lib/assemblyai/transcripts/types/page_details.rb +59 -33
  47. data/lib/assemblyai/transcripts/types/paragraphs_response.rb +37 -19
  48. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +4 -1
  49. data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +29 -15
  50. data/lib/assemblyai/transcripts/types/sentences_response.rb +37 -19
  51. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +62 -35
  52. data/lib/assemblyai/transcripts/types/severity_score_summary.rb +32 -16
  53. data/lib/assemblyai/transcripts/types/speech_model.rb +1 -0
  54. data/lib/assemblyai/transcripts/types/substitution_policy.rb +3 -1
  55. data/lib/assemblyai/transcripts/types/timestamp.rb +28 -14
  56. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +39 -19
  57. data/lib/assemblyai/transcripts/types/topic_detection_result.rb +40 -21
  58. data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +31 -15
  59. data/lib/assemblyai/transcripts/types/transcript.rb +512 -293
  60. data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +30 -15
  61. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +3 -2
  62. data/lib/assemblyai/transcripts/types/transcript_list.rb +33 -17
  63. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +60 -34
  64. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +334 -191
  65. data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +61 -33
  66. data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +30 -16
  67. data/lib/assemblyai/transcripts/types/transcript_sentence.rb +61 -33
  68. data/lib/assemblyai/transcripts/types/transcript_status.rb +2 -1
  69. data/lib/assemblyai/transcripts/types/transcript_utterance.rb +55 -31
  70. data/lib/assemblyai/transcripts/types/transcript_word.rb +55 -24
  71. data/lib/assemblyai/transcripts/types/word_search_match.rb +40 -20
  72. data/lib/assemblyai/transcripts/types/word_search_response.rb +36 -17
  73. data/lib/assemblyai/types/error.rb +32 -16
  74. data/lib/requests.rb +80 -34
  75. data/lib/types_export.rb +4 -3
  76. metadata +6 -5
  77. data/lib/assemblyai/realtime/types/audio_data.rb +0 -7
  78. data/lib/assemblyai/realtime/types/receive_message.rb +0 -87
@@ -2,60 +2,80 @@
2
2
 
3
3
  require_relative "audio_intelligence_model_status"
4
4
  require_relative "topic_detection_result"
5
+ require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module AssemblyAI
8
9
  class Transcripts
9
10
  # The result of the Topic Detection model, if it is enabled.
10
- # See [Topic Detection](https://www.assemblyai.com/docs/models/topic-detection) for more information.
11
+ # See [Topic Detection](https://www.assemblyai.com/docs/models/topic-detection)
12
+ # for more information.
11
13
  class TopicDetectionModelResult
12
- attr_reader :status, :results, :summary, :additional_properties
14
+ # @return [AssemblyAI::Transcripts::AudioIntelligenceModelStatus] The status of the Topic Detection model. Either success, or unavailable in the
15
+ # rare case that the model failed.
16
+ attr_reader :status
17
+ # @return [Array<AssemblyAI::Transcripts::TopicDetectionResult>] An array of results for the Topic Detection model
18
+ attr_reader :results
19
+ # @return [Hash{String => Float}] The overall relevance of topic to the entire audio file
20
+ attr_reader :summary
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
13
26
 
14
- # @param status [Transcripts::AudioIntelligenceModelStatus] The status of the Topic Detection model. Either success, or unavailable in the rare case that the model failed.
15
- # @param results [Array<Transcripts::TopicDetectionResult>] An array of results for the Topic Detection model
27
+ OMIT = Object.new
28
+
29
+ # @param status [AssemblyAI::Transcripts::AudioIntelligenceModelStatus] The status of the Topic Detection model. Either success, or unavailable in the
30
+ # rare case that the model failed.
31
+ # @param results [Array<AssemblyAI::Transcripts::TopicDetectionResult>] An array of results for the Topic Detection model
16
32
  # @param summary [Hash{String => Float}] The overall relevance of topic to the entire audio file
17
33
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
18
- # @return [Transcripts::TopicDetectionModelResult]
34
+ # @return [AssemblyAI::Transcripts::TopicDetectionModelResult]
19
35
  def initialize(status:, results:, summary:, additional_properties: nil)
20
- # @type [Transcripts::AudioIntelligenceModelStatus] The status of the Topic Detection model. Either success, or unavailable in the rare case that the model failed.
21
36
  @status = status
22
- # @type [Array<Transcripts::TopicDetectionResult>] An array of results for the Topic Detection model
23
37
  @results = results
24
- # @type [Hash{String => Float}] The overall relevance of topic to the entire audio file
25
38
  @summary = summary
26
- # @type [OpenStruct] Additional properties unmapped to the current class definition
27
39
  @additional_properties = additional_properties
40
+ @_field_set = { "status": status, "results": results, "summary": summary }
28
41
  end
29
42
 
30
43
  # Deserialize a JSON object to an instance of TopicDetectionModelResult
31
44
  #
32
- # @param json_object [JSON]
33
- # @return [Transcripts::TopicDetectionModelResult]
45
+ # @param json_object [String]
46
+ # @return [AssemblyAI::Transcripts::TopicDetectionModelResult]
34
47
  def self.from_json(json_object:)
35
48
  struct = JSON.parse(json_object, object_class: OpenStruct)
36
49
  parsed_json = JSON.parse(json_object)
37
- status = struct.status
50
+ status = struct["status"]
38
51
  results = parsed_json["results"]&.map do |v|
39
52
  v = v.to_json
40
- Transcripts::TopicDetectionResult.from_json(json_object: v)
53
+ AssemblyAI::Transcripts::TopicDetectionResult.from_json(json_object: v)
41
54
  end
42
- summary = struct.summary
43
- new(status: status, results: results, summary: summary, additional_properties: struct)
55
+ summary = struct["summary"]
56
+ new(
57
+ status: status,
58
+ results: results,
59
+ summary: summary,
60
+ additional_properties: struct
61
+ )
44
62
  end
45
63
 
46
64
  # Serialize an instance of TopicDetectionModelResult to a JSON object
47
65
  #
48
- # @return [JSON]
66
+ # @return [String]
49
67
  def to_json(*_args)
50
- { "status": @status, "results": @results, "summary": @summary }.to_json
68
+ @_field_set&.to_json
51
69
  end
52
70
 
53
- # 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.
71
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
72
+ # hash and check each fields type against the current object's property
73
+ # definitions.
54
74
  #
55
75
  # @param obj [Object]
56
76
  # @return [Void]
57
77
  def self.validate_raw(obj:)
58
- obj.status.is_a?(Transcripts::AudioIntelligenceModelStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
78
+ obj.status.is_a?(AssemblyAI::Transcripts::AudioIntelligenceModelStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
59
79
  obj.results.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.")
60
80
  obj.summary.is_a?(Hash) != false || raise("Passed value for field obj.summary is not the expected type, validation failed.")
61
81
  end
@@ -2,66 +2,85 @@
2
2
 
3
3
  require_relative "topic_detection_result_labels_item"
4
4
  require_relative "timestamp"
5
+ require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module AssemblyAI
8
9
  class Transcripts
9
10
  # The result of the topic detection model
10
11
  class TopicDetectionResult
11
- attr_reader :text, :labels, :timestamp, :additional_properties
12
+ # @return [String] The text in the transcript in which a detected topic occurs
13
+ attr_reader :text
14
+ # @return [Array<AssemblyAI::Transcripts::TopicDetectionResultLabelsItem>]
15
+ attr_reader :labels
16
+ # @return [AssemblyAI::Transcripts::Timestamp]
17
+ attr_reader :timestamp
18
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
19
+ attr_reader :additional_properties
20
+ # @return [Object]
21
+ attr_reader :_field_set
22
+ protected :_field_set
23
+
24
+ OMIT = Object.new
12
25
 
13
26
  # @param text [String] The text in the transcript in which a detected topic occurs
14
- # @param labels [Array<Transcripts::TopicDetectionResultLabelsItem>]
15
- # @param timestamp [Transcripts::Timestamp]
27
+ # @param labels [Array<AssemblyAI::Transcripts::TopicDetectionResultLabelsItem>]
28
+ # @param timestamp [AssemblyAI::Transcripts::Timestamp]
16
29
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
17
- # @return [Transcripts::TopicDetectionResult]
18
- def initialize(text:, labels: nil, timestamp: nil, additional_properties: nil)
19
- # @type [String] The text in the transcript in which a detected topic occurs
30
+ # @return [AssemblyAI::Transcripts::TopicDetectionResult]
31
+ def initialize(text:, labels: OMIT, timestamp: OMIT, additional_properties: nil)
20
32
  @text = text
21
- # @type [Array<Transcripts::TopicDetectionResultLabelsItem>]
22
- @labels = labels
23
- # @type [Transcripts::Timestamp]
24
- @timestamp = timestamp
25
- # @type [OpenStruct] Additional properties unmapped to the current class definition
33
+ @labels = labels if labels != OMIT
34
+ @timestamp = timestamp if timestamp != OMIT
26
35
  @additional_properties = additional_properties
36
+ @_field_set = { "text": text, "labels": labels, "timestamp": timestamp }.reject do |_k, v|
37
+ v == OMIT
38
+ end
27
39
  end
28
40
 
29
41
  # Deserialize a JSON object to an instance of TopicDetectionResult
30
42
  #
31
- # @param json_object [JSON]
32
- # @return [Transcripts::TopicDetectionResult]
43
+ # @param json_object [String]
44
+ # @return [AssemblyAI::Transcripts::TopicDetectionResult]
33
45
  def self.from_json(json_object:)
34
46
  struct = JSON.parse(json_object, object_class: OpenStruct)
35
47
  parsed_json = JSON.parse(json_object)
36
- text = struct.text
48
+ text = struct["text"]
37
49
  labels = parsed_json["labels"]&.map do |v|
38
50
  v = v.to_json
39
- Transcripts::TopicDetectionResultLabelsItem.from_json(json_object: v)
51
+ AssemblyAI::Transcripts::TopicDetectionResultLabelsItem.from_json(json_object: v)
40
52
  end
41
53
  if parsed_json["timestamp"].nil?
42
54
  timestamp = nil
43
55
  else
44
56
  timestamp = parsed_json["timestamp"].to_json
45
- timestamp = Transcripts::Timestamp.from_json(json_object: timestamp)
57
+ timestamp = AssemblyAI::Transcripts::Timestamp.from_json(json_object: timestamp)
46
58
  end
47
- new(text: text, labels: labels, timestamp: timestamp, additional_properties: struct)
59
+ new(
60
+ text: text,
61
+ labels: labels,
62
+ timestamp: timestamp,
63
+ additional_properties: struct
64
+ )
48
65
  end
49
66
 
50
67
  # Serialize an instance of TopicDetectionResult to a JSON object
51
68
  #
52
- # @return [JSON]
69
+ # @return [String]
53
70
  def to_json(*_args)
54
- { "text": @text, "labels": @labels, "timestamp": @timestamp }.to_json
71
+ @_field_set&.to_json
55
72
  end
56
73
 
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.
74
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
75
+ # hash and check each fields type against the current object's property
76
+ # definitions.
58
77
  #
59
78
  # @param obj [Object]
60
79
  # @return [Void]
61
80
  def self.validate_raw(obj:)
62
81
  obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
63
82
  obj.labels&.is_a?(Array) != false || raise("Passed value for field obj.labels is not the expected type, validation failed.")
64
- obj.timestamp.nil? || Transcripts::Timestamp.validate_raw(obj: obj.timestamp)
83
+ obj.timestamp.nil? || AssemblyAI::Transcripts::Timestamp.validate_raw(obj: obj.timestamp)
65
84
  end
66
85
  end
67
86
  end
@@ -1,45 +1,61 @@
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 TopicDetectionResultLabelsItem
8
- attr_reader :relevance, :label, :additional_properties
9
+ # @return [Float] How relevant the detected topic is of a detected topic
10
+ attr_reader :relevance
11
+ # @return [String] The IAB taxonomical label for the label of the detected topic, where > denotes
12
+ # supertopic/subtopic relationship
13
+ attr_reader :label
14
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
15
+ attr_reader :additional_properties
16
+ # @return [Object]
17
+ attr_reader :_field_set
18
+ protected :_field_set
19
+
20
+ OMIT = Object.new
9
21
 
10
22
  # @param relevance [Float] How relevant the detected topic is of a detected topic
11
- # @param label [String] The IAB taxonomical label for the label of the detected topic, where > denotes supertopic/subtopic relationship
23
+ # @param label [String] The IAB taxonomical label for the label of the detected topic, where > denotes
24
+ # supertopic/subtopic relationship
12
25
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
13
- # @return [Transcripts::TopicDetectionResultLabelsItem]
26
+ # @return [AssemblyAI::Transcripts::TopicDetectionResultLabelsItem]
14
27
  def initialize(relevance:, label:, additional_properties: nil)
15
- # @type [Float] How relevant the detected topic is of a detected topic
16
28
  @relevance = relevance
17
- # @type [String] The IAB taxonomical label for the label of the detected topic, where > denotes supertopic/subtopic relationship
18
29
  @label = label
19
- # @type [OpenStruct] Additional properties unmapped to the current class definition
20
30
  @additional_properties = additional_properties
31
+ @_field_set = { "relevance": relevance, "label": label }
21
32
  end
22
33
 
23
34
  # Deserialize a JSON object to an instance of TopicDetectionResultLabelsItem
24
35
  #
25
- # @param json_object [JSON]
26
- # @return [Transcripts::TopicDetectionResultLabelsItem]
36
+ # @param json_object [String]
37
+ # @return [AssemblyAI::Transcripts::TopicDetectionResultLabelsItem]
27
38
  def self.from_json(json_object:)
28
39
  struct = JSON.parse(json_object, object_class: OpenStruct)
29
- JSON.parse(json_object)
30
- relevance = struct.relevance
31
- label = struct.label
32
- new(relevance: relevance, label: label, additional_properties: struct)
40
+ relevance = struct["relevance"]
41
+ label = struct["label"]
42
+ new(
43
+ relevance: relevance,
44
+ label: label,
45
+ additional_properties: struct
46
+ )
33
47
  end
34
48
 
35
49
  # Serialize an instance of TopicDetectionResultLabelsItem to a JSON object
36
50
  #
37
- # @return [JSON]
51
+ # @return [String]
38
52
  def to_json(*_args)
39
- { "relevance": @relevance, "label": @label }.to_json
53
+ @_field_set&.to_json
40
54
  end
41
55
 
42
- # 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
+ # 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.
43
59
  #
44
60
  # @param obj [Object]
45
61
  # @return [Void]