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
@@ -1,46 +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
- # Object containing words or phrases to replace, and the word or phrase to replace with
8
+ # Object containing words or phrases to replace, and the word or phrase to replace
9
+ # with
8
10
  class TranscriptCustomSpelling
9
- attr_reader :from, :to, :additional_properties
11
+ # @return [Array<String>] Words or phrases to replace
12
+ attr_reader :from
13
+ # @return [String] Word or phrase to replace with
14
+ attr_reader :to
15
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
16
+ attr_reader :additional_properties
17
+ # @return [Object]
18
+ attr_reader :_field_set
19
+ protected :_field_set
20
+
21
+ OMIT = Object.new
10
22
 
11
23
  # @param from [Array<String>] Words or phrases to replace
12
24
  # @param to [String] Word or phrase to replace with
13
25
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
14
- # @return [Transcripts::TranscriptCustomSpelling]
26
+ # @return [AssemblyAI::Transcripts::TranscriptCustomSpelling]
15
27
  def initialize(from:, to:, additional_properties: nil)
16
- # @type [Array<String>] Words or phrases to replace
17
28
  @from = from
18
- # @type [String] Word or phrase to replace with
19
29
  @to = to
20
- # @type [OpenStruct] Additional properties unmapped to the current class definition
21
30
  @additional_properties = additional_properties
31
+ @_field_set = { "from": from, "to": to }
22
32
  end
23
33
 
24
34
  # Deserialize a JSON object to an instance of TranscriptCustomSpelling
25
35
  #
26
- # @param json_object [JSON]
27
- # @return [Transcripts::TranscriptCustomSpelling]
36
+ # @param json_object [String]
37
+ # @return [AssemblyAI::Transcripts::TranscriptCustomSpelling]
28
38
  def self.from_json(json_object:)
29
39
  struct = JSON.parse(json_object, object_class: OpenStruct)
30
- JSON.parse(json_object)
31
- from = struct.from
32
- to = struct.to
33
- new(from: from, to: to, additional_properties: struct)
40
+ from = struct["from"]
41
+ to = struct["to"]
42
+ new(
43
+ from: from,
44
+ to: to,
45
+ additional_properties: struct
46
+ )
34
47
  end
35
48
 
36
49
  # Serialize an instance of TranscriptCustomSpelling to a JSON object
37
50
  #
38
- # @return [JSON]
51
+ # @return [String]
39
52
  def to_json(*_args)
40
- { "from": @from, "to": @to }.to_json
53
+ @_field_set&.to_json
41
54
  end
42
55
 
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.
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.
44
59
  #
45
60
  # @param obj [Object]
46
61
  # @return [Void]
@@ -2,8 +2,9 @@
2
2
 
3
3
  module AssemblyAI
4
4
  class Transcripts
5
- # The language of your audio file. Possible values are found in [Supported Languages](https://www.assemblyai.com/docs/concepts/supported-languages).
6
- # The default value is 'en_us'.
5
+ # The language of your audio file. Possible values are found in [Supported
6
+ # Languages](https://www.assemblyai.com/docs/concepts/supported-languages).
7
+ # The default value is 'en_us'.
7
8
  class TranscriptLanguageCode
8
9
  EN = "en"
9
10
  EN_AU = "en_au"
@@ -2,31 +2,41 @@
2
2
 
3
3
  require_relative "page_details"
4
4
  require_relative "transcript_list_item"
5
+ require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module AssemblyAI
8
9
  class Transcripts
9
- # A list of transcripts. Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
10
+ # A list of transcripts. Transcripts are sorted from newest to oldest. The
11
+ # previous URL always points to a page with older transcripts.
10
12
  class TranscriptList
11
- attr_reader :page_details, :transcripts, :additional_properties
13
+ # @return [AssemblyAI::Transcripts::PageDetails]
14
+ attr_reader :page_details
15
+ # @return [Array<AssemblyAI::Transcripts::TranscriptListItem>]
16
+ attr_reader :transcripts
17
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
18
+ attr_reader :additional_properties
19
+ # @return [Object]
20
+ attr_reader :_field_set
21
+ protected :_field_set
12
22
 
13
- # @param page_details [Transcripts::PageDetails]
14
- # @param transcripts [Array<Transcripts::TranscriptListItem>]
23
+ OMIT = Object.new
24
+
25
+ # @param page_details [AssemblyAI::Transcripts::PageDetails]
26
+ # @param transcripts [Array<AssemblyAI::Transcripts::TranscriptListItem>]
15
27
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
16
- # @return [Transcripts::TranscriptList]
28
+ # @return [AssemblyAI::Transcripts::TranscriptList]
17
29
  def initialize(page_details:, transcripts:, additional_properties: nil)
18
- # @type [Transcripts::PageDetails]
19
30
  @page_details = page_details
20
- # @type [Array<Transcripts::TranscriptListItem>]
21
31
  @transcripts = transcripts
22
- # @type [OpenStruct] Additional properties unmapped to the current class definition
23
32
  @additional_properties = additional_properties
33
+ @_field_set = { "page_details": page_details, "transcripts": transcripts }
24
34
  end
25
35
 
26
36
  # Deserialize a JSON object to an instance of TranscriptList
27
37
  #
28
- # @param json_object [JSON]
29
- # @return [Transcripts::TranscriptList]
38
+ # @param json_object [String]
39
+ # @return [AssemblyAI::Transcripts::TranscriptList]
30
40
  def self.from_json(json_object:)
31
41
  struct = JSON.parse(json_object, object_class: OpenStruct)
32
42
  parsed_json = JSON.parse(json_object)
@@ -34,28 +44,34 @@ module AssemblyAI
34
44
  page_details = nil
35
45
  else
36
46
  page_details = parsed_json["page_details"].to_json
37
- page_details = Transcripts::PageDetails.from_json(json_object: page_details)
47
+ page_details = AssemblyAI::Transcripts::PageDetails.from_json(json_object: page_details)
38
48
  end
39
49
  transcripts = parsed_json["transcripts"]&.map do |v|
40
50
  v = v.to_json
41
- Transcripts::TranscriptListItem.from_json(json_object: v)
51
+ AssemblyAI::Transcripts::TranscriptListItem.from_json(json_object: v)
42
52
  end
43
- new(page_details: page_details, transcripts: transcripts, additional_properties: struct)
53
+ new(
54
+ page_details: page_details,
55
+ transcripts: transcripts,
56
+ additional_properties: struct
57
+ )
44
58
  end
45
59
 
46
60
  # Serialize an instance of TranscriptList to a JSON object
47
61
  #
48
- # @return [JSON]
62
+ # @return [String]
49
63
  def to_json(*_args)
50
- { "page_details": @page_details, "transcripts": @transcripts }.to_json
64
+ @_field_set&.to_json
51
65
  end
52
66
 
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.
67
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
68
+ # hash and check each fields type against the current object's property
69
+ # definitions.
54
70
  #
55
71
  # @param obj [Object]
56
72
  # @return [Void]
57
73
  def self.validate_raw(obj:)
58
- Transcripts::PageDetails.validate_raw(obj: obj.page_details)
74
+ AssemblyAI::Transcripts::PageDetails.validate_raw(obj: obj.page_details)
59
75
  obj.transcripts.is_a?(Array) != false || raise("Passed value for field obj.transcripts is not the expected type, validation failed.")
60
76
  end
61
77
  end
@@ -2,83 +2,109 @@
2
2
 
3
3
  require_relative "transcript_status"
4
4
  require "date"
5
+ require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module AssemblyAI
8
9
  class Transcripts
9
10
  class TranscriptListItem
10
- attr_reader :id, :resource_url, :status, :created, :completed, :audio_url, :error, :additional_properties
11
+ # @return [String]
12
+ attr_reader :id
13
+ # @return [String]
14
+ attr_reader :resource_url
15
+ # @return [AssemblyAI::Transcripts::TranscriptStatus]
16
+ attr_reader :status
17
+ # @return [DateTime]
18
+ attr_reader :created
19
+ # @return [DateTime]
20
+ attr_reader :completed
21
+ # @return [String]
22
+ attr_reader :audio_url
23
+ # @return [String] Error message of why the transcript failed
24
+ attr_reader :error
25
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
26
+ attr_reader :additional_properties
27
+ # @return [Object]
28
+ attr_reader :_field_set
29
+ protected :_field_set
30
+
31
+ OMIT = Object.new
11
32
 
12
33
  # @param id [String]
13
34
  # @param resource_url [String]
14
- # @param status [Transcripts::TranscriptStatus]
35
+ # @param status [AssemblyAI::Transcripts::TranscriptStatus]
15
36
  # @param created [DateTime]
16
37
  # @param completed [DateTime]
17
38
  # @param audio_url [String]
18
39
  # @param error [String] Error message of why the transcript failed
19
40
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
20
- # @return [Transcripts::TranscriptListItem]
21
- def initialize(id:, resource_url:, status:, created:, completed:, audio_url:, error: nil,
41
+ # @return [AssemblyAI::Transcripts::TranscriptListItem]
42
+ def initialize(id:, resource_url:, status:, created:, completed:, audio_url:, error: OMIT,
22
43
  additional_properties: nil)
23
- # @type [String]
24
44
  @id = id
25
- # @type [String]
26
45
  @resource_url = resource_url
27
- # @type [Transcripts::TranscriptStatus]
28
46
  @status = status
29
- # @type [DateTime]
30
47
  @created = created
31
- # @type [DateTime]
32
48
  @completed = completed
33
- # @type [String]
34
49
  @audio_url = audio_url
35
- # @type [String] Error message of why the transcript failed
36
- @error = error
37
- # @type [OpenStruct] Additional properties unmapped to the current class definition
50
+ @error = error if error != OMIT
38
51
  @additional_properties = additional_properties
52
+ @_field_set = {
53
+ "id": id,
54
+ "resource_url": resource_url,
55
+ "status": status,
56
+ "created": created,
57
+ "completed": completed,
58
+ "audio_url": audio_url,
59
+ "error": error
60
+ }.reject do |_k, v|
61
+ v == OMIT
62
+ end
39
63
  end
40
64
 
41
65
  # Deserialize a JSON object to an instance of TranscriptListItem
42
66
  #
43
- # @param json_object [JSON]
44
- # @return [Transcripts::TranscriptListItem]
67
+ # @param json_object [String]
68
+ # @return [AssemblyAI::Transcripts::TranscriptListItem]
45
69
  def self.from_json(json_object:)
46
70
  struct = JSON.parse(json_object, object_class: OpenStruct)
47
71
  parsed_json = JSON.parse(json_object)
48
- id = struct.id
49
- resource_url = struct.resource_url
50
- status = struct.status
72
+ id = struct["id"]
73
+ resource_url = struct["resource_url"]
74
+ status = struct["status"]
51
75
  created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
52
76
  completed = (DateTime.parse(parsed_json["completed"]) unless parsed_json["completed"].nil?)
53
- audio_url = struct.audio_url
54
- error = struct.error
55
- new(id: id, resource_url: resource_url, status: status, created: created, completed: completed,
56
- audio_url: audio_url, error: error, additional_properties: struct)
77
+ audio_url = struct["audio_url"]
78
+ error = struct["error"]
79
+ new(
80
+ id: id,
81
+ resource_url: resource_url,
82
+ status: status,
83
+ created: created,
84
+ completed: completed,
85
+ audio_url: audio_url,
86
+ error: error,
87
+ additional_properties: struct
88
+ )
57
89
  end
58
90
 
59
91
  # Serialize an instance of TranscriptListItem to a JSON object
60
92
  #
61
- # @return [JSON]
93
+ # @return [String]
62
94
  def to_json(*_args)
63
- {
64
- "id": @id,
65
- "resource_url": @resource_url,
66
- "status": @status,
67
- "created": @created,
68
- "completed": @completed,
69
- "audio_url": @audio_url,
70
- "error": @error
71
- }.to_json
95
+ @_field_set&.to_json
72
96
  end
73
97
 
74
- # 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.
98
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
99
+ # hash and check each fields type against the current object's property
100
+ # definitions.
75
101
  #
76
102
  # @param obj [Object]
77
103
  # @return [Void]
78
104
  def self.validate_raw(obj:)
79
105
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
80
106
  obj.resource_url.is_a?(String) != false || raise("Passed value for field obj.resource_url is not the expected type, validation failed.")
81
- obj.status.is_a?(Transcripts::TranscriptStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
107
+ obj.status.is_a?(AssemblyAI::Transcripts::TranscriptStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
82
108
  obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
83
109
  obj.completed.is_a?(DateTime) != false || raise("Passed value for field obj.completed is not the expected type, validation failed.")
84
110
  obj.audio_url.is_a?(String) != false || raise("Passed value for field obj.audio_url is not the expected type, validation failed.")