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.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/lib/assemblyai/files/client.rb +63 -0
  3. data/lib/assemblyai/files/types/uploaded_file.rb +47 -0
  4. data/lib/assemblyai/lemur/client.rb +390 -0
  5. data/lib/assemblyai/lemur/types/lemur_action_items_response.rb +52 -0
  6. data/lib/assemblyai/lemur/types/lemur_base_params.rb +99 -0
  7. data/lib/assemblyai/lemur/types/lemur_base_params_context.rb +75 -0
  8. data/lib/assemblyai/lemur/types/lemur_base_response.rb +47 -0
  9. data/lib/assemblyai/lemur/types/lemur_model.rb +13 -0
  10. data/lib/assemblyai/lemur/types/lemur_question.rb +74 -0
  11. data/lib/assemblyai/lemur/types/lemur_question_answer.rb +53 -0
  12. data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +56 -0
  13. data/lib/assemblyai/lemur/types/lemur_question_context.rb +75 -0
  14. data/lib/assemblyai/lemur/types/lemur_summary_response.rb +52 -0
  15. data/lib/assemblyai/lemur/types/lemur_task_response.rb +52 -0
  16. data/lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb +58 -0
  17. data/lib/assemblyai/realtime/client.rb +61 -0
  18. data/lib/assemblyai/realtime/types/audio_data.rb +7 -0
  19. data/lib/assemblyai/realtime/types/audio_encoding.rb +8 -0
  20. data/lib/assemblyai/realtime/types/final_transcript.rb +107 -0
  21. data/lib/assemblyai/realtime/types/message_type.rb +13 -0
  22. data/lib/assemblyai/realtime/types/partial_transcript.rb +94 -0
  23. data/lib/assemblyai/realtime/types/realtime_base_message.rb +48 -0
  24. data/lib/assemblyai/realtime/types/realtime_base_transcript.rb +87 -0
  25. data/lib/assemblyai/realtime/types/realtime_error.rb +47 -0
  26. data/lib/assemblyai/realtime/types/realtime_message.rb +115 -0
  27. data/lib/assemblyai/realtime/types/realtime_temporary_token_response.rb +47 -0
  28. data/lib/assemblyai/realtime/types/realtime_transcript.rb +76 -0
  29. data/lib/assemblyai/realtime/types/realtime_transcript_type.rb +8 -0
  30. data/lib/assemblyai/realtime/types/session_begins.rb +58 -0
  31. data/lib/assemblyai/realtime/types/session_terminated.rb +47 -0
  32. data/lib/assemblyai/realtime/types/terminate_session.rb +56 -0
  33. data/lib/assemblyai/realtime/types/word.rb +62 -0
  34. data/lib/assemblyai/transcripts/client.rb +525 -0
  35. data/lib/assemblyai/transcripts/polling_client.rb +173 -0
  36. data/lib/assemblyai/transcripts/types/audio_intelligence_model_status.rb +8 -0
  37. data/lib/assemblyai/transcripts/types/auto_highlight_result.rb +66 -0
  38. data/lib/assemblyai/transcripts/types/auto_highlights_result.rb +53 -0
  39. data/lib/assemblyai/transcripts/types/chapter.rb +68 -0
  40. data/lib/assemblyai/transcripts/types/content_safety_label.rb +57 -0
  41. data/lib/assemblyai/transcripts/types/content_safety_label_result.rb +84 -0
  42. data/lib/assemblyai/transcripts/types/content_safety_labels_result.rb +75 -0
  43. data/lib/assemblyai/transcripts/types/entity.rb +69 -0
  44. data/lib/assemblyai/transcripts/types/entity_type.rb +38 -0
  45. data/lib/assemblyai/transcripts/types/page_details.rb +74 -0
  46. data/lib/assemblyai/transcripts/types/paragraphs_response.rb +67 -0
  47. data/lib/assemblyai/transcripts/types/pii_policy.rb +36 -0
  48. data/lib/assemblyai/transcripts/types/polling_options.rb +21 -0
  49. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +8 -0
  50. data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +53 -0
  51. data/lib/assemblyai/transcripts/types/redacted_audio_status.rb +7 -0
  52. data/lib/assemblyai/transcripts/types/sentences_response.rb +67 -0
  53. data/lib/assemblyai/transcripts/types/sentiment.rb +8 -0
  54. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +82 -0
  55. data/lib/assemblyai/transcripts/types/severity_score_summary.rb +57 -0
  56. data/lib/assemblyai/transcripts/types/speech_model.rb +7 -0
  57. data/lib/assemblyai/transcripts/types/substitution_policy.rb +8 -0
  58. data/lib/assemblyai/transcripts/types/subtitle_format.rb +8 -0
  59. data/lib/assemblyai/transcripts/types/summary_model.rb +8 -0
  60. data/lib/assemblyai/transcripts/types/summary_type.rb +14 -0
  61. data/lib/assemblyai/transcripts/types/timestamp.rb +53 -0
  62. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +68 -0
  63. data/lib/assemblyai/transcripts/types/topic_detection_result.rb +68 -0
  64. data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +52 -0
  65. data/lib/assemblyai/transcripts/types/transcript.rb +454 -0
  66. data/lib/assemblyai/transcripts/types/transcript_boost_param.rb +8 -0
  67. data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +53 -0
  68. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +29 -0
  69. data/lib/assemblyai/transcripts/types/transcript_list.rb +62 -0
  70. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +82 -0
  71. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +280 -0
  72. data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +84 -0
  73. data/lib/assemblyai/transcripts/types/transcript_sentence.rb +84 -0
  74. data/lib/assemblyai/transcripts/types/transcript_status.rb +8 -0
  75. data/lib/assemblyai/transcripts/types/transcript_utterance.rb +84 -0
  76. data/lib/assemblyai/transcripts/types/transcript_word.rb +68 -0
  77. data/lib/assemblyai/transcripts/types/word_search_match.rb +63 -0
  78. data/lib/assemblyai/transcripts/types/word_search_response.rb +61 -0
  79. data/lib/assemblyai/transcripts/types/word_search_timestamp.rb +7 -0
  80. data/lib/assemblyai/types/error.rb +50 -0
  81. data/lib/assemblyai.rb +48 -0
  82. data/lib/environment.rb +7 -0
  83. data/lib/gemconfig.rb +14 -0
  84. data/lib/requests.rb +87 -0
  85. data/lib/types_export.rb +75 -0
  86. metadata +170 -0
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module AssemblyAI
6
+ class Transcripts
7
+ # Timestamp containing a start and end property in milliseconds
8
+ class Timestamp
9
+ attr_reader :start, :end_, :additional_properties
10
+
11
+ # @param start [Integer] The start time in milliseconds
12
+ # @param end_ [Integer] The end time in milliseconds
13
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
14
+ # @return [Transcripts::Timestamp]
15
+ def initialize(start:, end_:, additional_properties: nil)
16
+ # @type [Integer] The start time in milliseconds
17
+ @start = start
18
+ # @type [Integer] The end time in milliseconds
19
+ @end_ = end_
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 Timestamp
25
+ #
26
+ # @param json_object [JSON]
27
+ # @return [Transcripts::Timestamp]
28
+ def self.from_json(json_object:)
29
+ struct = JSON.parse(json_object, object_class: OpenStruct)
30
+ JSON.parse(json_object)
31
+ start = struct.start
32
+ end_ = struct.end
33
+ new(start: start, end_: end_, additional_properties: struct)
34
+ end
35
+
36
+ # Serialize an instance of Timestamp to a JSON object
37
+ #
38
+ # @return [JSON]
39
+ def to_json(*_args)
40
+ { "start": @start, "end": @end_ }.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.start.is_a?(Integer) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
49
+ obj.end_.is_a?(Integer) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "audio_intelligence_model_status"
4
+ require_relative "topic_detection_result"
5
+ require "json"
6
+
7
+ module AssemblyAI
8
+ class Transcripts
9
+ # 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
+ class TopicDetectionModelResult
12
+ attr_reader :status, :results, :summary, :additional_properties
13
+
14
+ # @param status [AUDIO_INTELLIGENCE_MODEL_STATUS] 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
16
+ # @param summary [Hash{String => String}] The overall relevance of topic to the entire audio file
17
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
18
+ # @return [Transcripts::TopicDetectionModelResult]
19
+ def initialize(status:, results:, summary:, additional_properties: nil)
20
+ # @type [AUDIO_INTELLIGENCE_MODEL_STATUS] The status of the Topic Detection model. Either success, or unavailable in the rare case that the model failed.
21
+ @status = status
22
+ # @type [Array<Transcripts::TopicDetectionResult>] An array of results for the Topic Detection model
23
+ @results = results
24
+ # @type [Hash{String => String}] The overall relevance of topic to the entire audio file
25
+ @summary = summary
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 TopicDetectionModelResult
31
+ #
32
+ # @param json_object [JSON]
33
+ # @return [Transcripts::TopicDetectionModelResult]
34
+ def self.from_json(json_object:)
35
+ struct = JSON.parse(json_object, object_class: OpenStruct)
36
+ parsed_json = JSON.parse(json_object)
37
+ status = Transcripts::AUDIO_INTELLIGENCE_MODEL_STATUS.key(parsed_json["status"]) || parsed_json["status"]
38
+ results = parsed_json["results"]&.map do |v|
39
+ v = v.to_json
40
+ Transcripts::TopicDetectionResult.from_json(json_object: v)
41
+ end
42
+ summary = struct.summary
43
+ new(status: status, results: results, summary: summary, additional_properties: struct)
44
+ end
45
+
46
+ # Serialize an instance of TopicDetectionModelResult to a JSON object
47
+ #
48
+ # @return [JSON]
49
+ def to_json(*_args)
50
+ {
51
+ "status": Transcripts::AUDIO_INTELLIGENCE_MODEL_STATUS[@status] || @status,
52
+ "results": @results,
53
+ "summary": @summary
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.status.is_a?(Transcripts::AUDIO_INTELLIGENCE_MODEL_STATUS) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
63
+ obj.results.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.")
64
+ obj.summary.is_a?(Hash) != false || raise("Passed value for field obj.summary is not the expected type, validation failed.")
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "topic_detection_result_labels_item"
4
+ require_relative "timestamp"
5
+ require "json"
6
+
7
+ module AssemblyAI
8
+ class Transcripts
9
+ # The result of the topic detection model
10
+ class TopicDetectionResult
11
+ attr_reader :text, :labels, :timestamp, :additional_properties
12
+
13
+ # @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]
16
+ # @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
20
+ @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
26
+ @additional_properties = additional_properties
27
+ end
28
+
29
+ # Deserialize a JSON object to an instance of TopicDetectionResult
30
+ #
31
+ # @param json_object [JSON]
32
+ # @return [Transcripts::TopicDetectionResult]
33
+ def self.from_json(json_object:)
34
+ struct = JSON.parse(json_object, object_class: OpenStruct)
35
+ parsed_json = JSON.parse(json_object)
36
+ text = struct.text
37
+ labels = parsed_json["labels"]&.map do |v|
38
+ v = v.to_json
39
+ Transcripts::TopicDetectionResultLabelsItem.from_json(json_object: v)
40
+ end
41
+ if parsed_json["timestamp"].nil?
42
+ timestamp = nil
43
+ else
44
+ timestamp = parsed_json["timestamp"].to_json
45
+ timestamp = Transcripts::Timestamp.from_json(json_object: timestamp)
46
+ end
47
+ new(text: text, labels: labels, timestamp: timestamp, additional_properties: struct)
48
+ end
49
+
50
+ # Serialize an instance of TopicDetectionResult to a JSON object
51
+ #
52
+ # @return [JSON]
53
+ def to_json(*_args)
54
+ { "text": @text, "labels": @labels, "timestamp": @timestamp }.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.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
63
+ 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)
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module AssemblyAI
6
+ class Transcripts
7
+ class TopicDetectionResultLabelsItem
8
+ attr_reader :relevance, :label, :additional_properties
9
+
10
+ # @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
12
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
13
+ # @return [Transcripts::TopicDetectionResultLabelsItem]
14
+ def initialize(relevance:, label:, additional_properties: nil)
15
+ # @type [Float] How relevant the detected topic is of a detected topic
16
+ @relevance = relevance
17
+ # @type [String] The IAB taxonomical label for the label of the detected topic, where > denotes supertopic/subtopic relationship
18
+ @label = label
19
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
20
+ @additional_properties = additional_properties
21
+ end
22
+
23
+ # Deserialize a JSON object to an instance of TopicDetectionResultLabelsItem
24
+ #
25
+ # @param json_object [JSON]
26
+ # @return [Transcripts::TopicDetectionResultLabelsItem]
27
+ def self.from_json(json_object:)
28
+ 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)
33
+ end
34
+
35
+ # Serialize an instance of TopicDetectionResultLabelsItem to a JSON object
36
+ #
37
+ # @return [JSON]
38
+ def to_json(*_args)
39
+ { "relevance": @relevance, "label": @label }.to_json
40
+ end
41
+
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.
43
+ #
44
+ # @param obj [Object]
45
+ # @return [Void]
46
+ def self.validate_raw(obj:)
47
+ obj.relevance.is_a?(Float) != false || raise("Passed value for field obj.relevance is not the expected type, validation failed.")
48
+ obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
49
+ end
50
+ end
51
+ end
52
+ end