assemblyai 1.0.0.pre.beta → 1.0.0.pre.beta.3

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/assemblyai/lemur/client.rb +16 -16
  3. data/lib/assemblyai/lemur/types/lemur_base_params.rb +5 -5
  4. data/lib/assemblyai/lemur/types/lemur_base_params_context.rb +3 -29
  5. data/lib/assemblyai/lemur/types/lemur_model.rb +7 -7
  6. data/lib/assemblyai/lemur/types/lemur_question_context.rb +3 -29
  7. data/lib/assemblyai/realtime/types/audio_encoding.rb +5 -2
  8. data/lib/assemblyai/realtime/types/configure_end_utterance_silence_threshold.rb +48 -0
  9. data/lib/assemblyai/realtime/types/force_end_utterance.rb +48 -0
  10. data/lib/assemblyai/realtime/types/message_type.rb +6 -7
  11. data/lib/assemblyai/realtime/types/realtime_base_message.rb +6 -6
  12. data/lib/assemblyai/realtime/types/realtime_message.rb +6 -35
  13. data/lib/assemblyai/realtime/types/realtime_transcript.rb +3 -29
  14. data/lib/assemblyai/realtime/types/realtime_transcript_type.rb +4 -2
  15. data/lib/assemblyai/realtime/types/terminate_session.rb +5 -14
  16. data/lib/assemblyai/transcripts/client.rb +20 -20
  17. data/lib/assemblyai/transcripts/list_by_url_client.rb +57 -0
  18. data/lib/assemblyai/transcripts/polling_client.rb +27 -25
  19. data/lib/assemblyai/transcripts/types/audio_intelligence_model_status.rb +5 -2
  20. data/lib/assemblyai/transcripts/types/content_safety_labels_result.rb +5 -5
  21. data/lib/assemblyai/transcripts/types/entity.rb +6 -11
  22. data/lib/assemblyai/transcripts/types/entity_type.rb +32 -32
  23. data/lib/assemblyai/transcripts/types/pii_policy.rb +29 -30
  24. data/lib/assemblyai/transcripts/types/polling_options.rb +14 -15
  25. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +5 -2
  26. data/lib/assemblyai/transcripts/types/sentiment.rb +5 -2
  27. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +6 -6
  28. data/lib/assemblyai/transcripts/types/speech_model.rb +4 -1
  29. data/lib/assemblyai/transcripts/types/substitution_policy.rb +5 -2
  30. data/lib/assemblyai/transcripts/types/subtitle_format.rb +5 -2
  31. data/lib/assemblyai/transcripts/types/summary_model.rb +6 -2
  32. data/lib/assemblyai/transcripts/types/summary_type.rb +8 -8
  33. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +5 -9
  34. data/lib/assemblyai/transcripts/types/transcript.rb +26 -29
  35. data/lib/assemblyai/transcripts/types/transcript_boost_param.rb +6 -2
  36. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +24 -23
  37. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +5 -5
  38. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +36 -39
  39. data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +54 -0
  40. data/lib/assemblyai/transcripts/types/transcript_ready_status.rb +11 -0
  41. data/lib/assemblyai/transcripts/types/transcript_status.rb +7 -2
  42. data/lib/assemblyai.rb +1 -0
  43. data/lib/requests.rb +28 -2
  44. data/lib/types_export.rb +9 -5
  45. metadata +57 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc0caf7b84497b13453af130bf9ed562274853b8a40c27c84dbe0e485271f099
4
- data.tar.gz: fa25a137746aeb43fd13427e7e8c7de382b0a6684744fa7c805f32b2c9ffcc45
3
+ metadata.gz: 82e3b0e81020edc6f6bd8589a23b2d30c78c2138f6b5a9ea1762371c92eacf37
4
+ data.tar.gz: c7a833cd083ddc051a45cb3a7f27ef5e8eb3b7915808360e5cfe60aa23a5b308
5
5
  SHA512:
6
- metadata.gz: 3e6c4c159194b38ed20d04228f253892ec24a4a4550a6ad1f29601a790689d833d5b608a5d8ba19a0fa8cf6585a8af1c5039a62f32d3b3c8664f2aceba68c2cf
7
- data.tar.gz: 5bffb7383c0b3e0e7ff9c9128c3022db428746beed340222157c49cf6b993f95d1a7cd60e93843cbfd3cd17ff6c4e9e3029b10fb4746a2d5adbe099077eda58f
6
+ metadata.gz: b064a231af8d12c62c817e8bc9708fc6657b725f13b4608869c4f323f5a3f88e88bfa57c32a4b1b91d3436f42c0f514d7f464cdd125718bf4c4b331033bb26dc
7
+ data.tar.gz: f462ce60f2ca15536c09cdab1fa4f0a81033bb80ac745e9dbf8dc1268b3129465ddebec0ebdb37b07c1b328b8051f6c7fdfb4bccfcb9097cf4e30e685b8c513e
@@ -28,8 +28,8 @@ module AssemblyAI
28
28
  # Use either transcript_ids or input_text as input into LeMUR.
29
29
  # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
30
30
  # Use either transcript_ids or input_text as input into LeMUR.
31
- # @param context [Hash] Context to provide the model. This can be a string or a free-form JSON value.Request of type Lemur::LemurBaseParamsContext, as a Hash
32
- # @param final_model [LEMUR_MODEL] The model that is used for the final prompt after compression is performed.
31
+ # @param context [String, Hash{String => String}] Context to provide the model. This can be a string or a free-form JSON value.
32
+ # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
33
33
  # Defaults to "default".
34
34
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
35
35
  # @param temperature [Float] The temperature to use for the model.
@@ -66,8 +66,8 @@ module AssemblyAI
66
66
  # Use either transcript_ids or input_text as input into LeMUR.
67
67
  # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
68
68
  # Use either transcript_ids or input_text as input into LeMUR.
69
- # @param context [Hash] Context to provide the model. This can be a string or a free-form JSON value.Request of type Lemur::LemurBaseParamsContext, as a Hash
70
- # @param final_model [LEMUR_MODEL] The model that is used for the final prompt after compression is performed.
69
+ # @param context [String, Hash{String => String}] Context to provide the model. This can be a string or a free-form JSON value.
70
+ # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
71
71
  # Defaults to "default".
72
72
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
73
73
  # @param temperature [Float] The temperature to use for the model.
@@ -104,8 +104,8 @@ module AssemblyAI
104
104
  # Use either transcript_ids or input_text as input into LeMUR.
105
105
  # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
106
106
  # Use either transcript_ids or input_text as input into LeMUR.
107
- # @param context [Hash] Context to provide the model. This can be a string or a free-form JSON value.Request of type Lemur::LemurBaseParamsContext, as a Hash
108
- # @param final_model [LEMUR_MODEL] The model that is used for the final prompt after compression is performed.
107
+ # @param context [String, Hash{String => String}] Context to provide the model. This can be a string or a free-form JSON value.
108
+ # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
109
109
  # Defaults to "default".
110
110
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
111
111
  # @param temperature [Float] The temperature to use for the model.
@@ -146,8 +146,8 @@ module AssemblyAI
146
146
  # Use either transcript_ids or input_text as input into LeMUR.
147
147
  # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
148
148
  # Use either transcript_ids or input_text as input into LeMUR.
149
- # @param context [Hash] Context to provide the model. This can be a string or a free-form JSON value.Request of type Lemur::LemurBaseParamsContext, as a Hash
150
- # @param final_model [LEMUR_MODEL] The model that is used for the final prompt after compression is performed.
149
+ # @param context [String, Hash{String => String}] Context to provide the model. This can be a string or a free-form JSON value.
150
+ # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
151
151
  # Defaults to "default".
152
152
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
153
153
  # @param temperature [Float] The temperature to use for the model.
@@ -211,8 +211,8 @@ module AssemblyAI
211
211
  # Use either transcript_ids or input_text as input into LeMUR.
212
212
  # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
213
213
  # Use either transcript_ids or input_text as input into LeMUR.
214
- # @param context [Hash] Context to provide the model. This can be a string or a free-form JSON value.Request of type Lemur::LemurBaseParamsContext, as a Hash
215
- # @param final_model [LEMUR_MODEL] The model that is used for the final prompt after compression is performed.
214
+ # @param context [String, Hash{String => String}] Context to provide the model. This can be a string or a free-form JSON value.
215
+ # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
216
216
  # Defaults to "default".
217
217
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
218
218
  # @param temperature [Float] The temperature to use for the model.
@@ -251,8 +251,8 @@ module AssemblyAI
251
251
  # Use either transcript_ids or input_text as input into LeMUR.
252
252
  # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
253
253
  # Use either transcript_ids or input_text as input into LeMUR.
254
- # @param context [Hash] Context to provide the model. This can be a string or a free-form JSON value.Request of type Lemur::LemurBaseParamsContext, as a Hash
255
- # @param final_model [LEMUR_MODEL] The model that is used for the final prompt after compression is performed.
254
+ # @param context [String, Hash{String => String}] Context to provide the model. This can be a string or a free-form JSON value.
255
+ # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
256
256
  # Defaults to "default".
257
257
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
258
258
  # @param temperature [Float] The temperature to use for the model.
@@ -291,8 +291,8 @@ module AssemblyAI
291
291
  # Use either transcript_ids or input_text as input into LeMUR.
292
292
  # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
293
293
  # Use either transcript_ids or input_text as input into LeMUR.
294
- # @param context [Hash] Context to provide the model. This can be a string or a free-form JSON value.Request of type Lemur::LemurBaseParamsContext, as a Hash
295
- # @param final_model [LEMUR_MODEL] The model that is used for the final prompt after compression is performed.
294
+ # @param context [String, Hash{String => String}] Context to provide the model. This can be a string or a free-form JSON value.
295
+ # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
296
296
  # Defaults to "default".
297
297
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
298
298
  # @param temperature [Float] The temperature to use for the model.
@@ -335,8 +335,8 @@ module AssemblyAI
335
335
  # Use either transcript_ids or input_text as input into LeMUR.
336
336
  # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
337
337
  # Use either transcript_ids or input_text as input into LeMUR.
338
- # @param context [Hash] Context to provide the model. This can be a string or a free-form JSON value.Request of type Lemur::LemurBaseParamsContext, as a Hash
339
- # @param final_model [LEMUR_MODEL] The model that is used for the final prompt after compression is performed.
338
+ # @param context [String, Hash{String => String}] Context to provide the model. This can be a string or a free-form JSON value.
339
+ # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
340
340
  # Defaults to "default".
341
341
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
342
342
  # @param temperature [Float] The temperature to use for the model.
@@ -15,7 +15,7 @@ module AssemblyAI
15
15
  # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
16
16
  # Use either transcript_ids or input_text as input into LeMUR.
17
17
  # @param context [Lemur::LemurBaseParamsContext] Context to provide the model. This can be a string or a free-form JSON value.
18
- # @param final_model [LEMUR_MODEL] The model that is used for the final prompt after compression is performed.
18
+ # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
19
19
  # Defaults to "default".
20
20
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
21
21
  # @param temperature [Float] The temperature to use for the model.
@@ -33,7 +33,7 @@ module AssemblyAI
33
33
  @input_text = input_text
34
34
  # @type [Lemur::LemurBaseParamsContext] Context to provide the model. This can be a string or a free-form JSON value.
35
35
  @context = context
36
- # @type [LEMUR_MODEL] The model that is used for the final prompt after compression is performed.
36
+ # @type [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
37
37
  # Defaults to "default".
38
38
  @final_model = final_model
39
39
  # @type [Integer] Max output size in tokens, up to 4000
@@ -61,7 +61,7 @@ module AssemblyAI
61
61
  context = parsed_json["context"].to_json
62
62
  context = Lemur::LemurBaseParamsContext.from_json(json_object: context)
63
63
  end
64
- final_model = Lemur::LEMUR_MODEL.key(parsed_json["final_model"]) || parsed_json["final_model"]
64
+ final_model = struct.final_model
65
65
  max_output_size = struct.max_output_size
66
66
  temperature = struct.temperature
67
67
  new(transcript_ids: transcript_ids, input_text: input_text, context: context, final_model: final_model,
@@ -76,7 +76,7 @@ module AssemblyAI
76
76
  "transcript_ids": @transcript_ids,
77
77
  "input_text": @input_text,
78
78
  "context": @context,
79
- "final_model": Lemur::LEMUR_MODEL[@final_model] || @final_model,
79
+ "final_model": @final_model,
80
80
  "max_output_size": @max_output_size,
81
81
  "temperature": @temperature
82
82
  }.to_json
@@ -90,7 +90,7 @@ module AssemblyAI
90
90
  obj.transcript_ids&.is_a?(Array) != false || raise("Passed value for field obj.transcript_ids is not the expected type, validation failed.")
91
91
  obj.input_text&.is_a?(String) != false || raise("Passed value for field obj.input_text is not the expected type, validation failed.")
92
92
  obj.context.nil? || Lemur::LemurBaseParamsContext.validate_raw(obj: obj.context)
93
- obj.final_model&.is_a?(Lemur::LEMUR_MODEL) != false || raise("Passed value for field obj.final_model is not the expected type, validation failed.")
93
+ obj.final_model&.is_a?(Lemur::LemurModel) != false || raise("Passed value for field obj.final_model is not the expected type, validation failed.")
94
94
  obj.max_output_size&.is_a?(Integer) != false || raise("Passed value for field obj.max_output_size is not the expected type, validation failed.")
95
95
  obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.")
96
96
  end
@@ -6,15 +6,6 @@ module AssemblyAI
6
6
  class Lemur
7
7
  # Context to provide the model. This can be a string or a free-form JSON value.
8
8
  class LemurBaseParamsContext
9
- attr_reader :member
10
- alias kind_of? is_a?
11
- # @param member [Object]
12
- # @return [Lemur::LemurBaseParamsContext]
13
- def initialize(member:)
14
- # @type [Object]
15
- @member = member
16
- end
17
-
18
9
  # Deserialize a JSON object to an instance of LemurBaseParamsContext
19
10
  #
20
11
  # @param json_object [JSON]
@@ -23,26 +14,17 @@ module AssemblyAI
23
14
  struct = JSON.parse(json_object, object_class: OpenStruct)
24
15
  begin
25
16
  struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.")
26
- member = json_object
27
- return new(member: member)
17
+ return json_object
28
18
  rescue StandardError
29
19
  # noop
30
20
  end
31
21
  begin
32
22
  struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.")
33
- member = json_object
34
- return new(member: member)
23
+ return json_object
35
24
  rescue StandardError
36
25
  # noop
37
26
  end
38
- new(member: struct)
39
- end
40
-
41
- # For Union Types, to_json functionality is delegated to the wrapped member.
42
- #
43
- # @return [JSON]
44
- def to_json(*_args)
45
- @member.to_json
27
+ struct
46
28
  end
47
29
 
48
30
  # 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,14 +44,6 @@ module AssemblyAI
62
44
  end
63
45
  raise("Passed value matched no type within the union, validation failed.")
64
46
  end
65
-
66
- # For Union Types, is_a? functionality is delegated to the wrapped member.
67
- #
68
- # @param obj [Object]
69
- # @return [Boolean]
70
- def is_a?(obj)
71
- @member.is_a?(obj)
72
- end
73
47
  end
74
48
  end
75
49
  end
@@ -2,12 +2,12 @@
2
2
 
3
3
  module AssemblyAI
4
4
  class Lemur
5
- # @type [LEMUR_MODEL]
6
- LEMUR_MODEL = {
7
- default: "default",
8
- basic: "basic",
9
- assemblyai_mistral7b: "assemblyai/mistral-7b",
10
- anthropic_claude21: "anthropic/claude-2-1"
11
- }.freeze
5
+ # The model that is used for the final prompt after compression is performed.
6
+ class LemurModel
7
+ DEFAULT = "default"
8
+ BASIC = "basic"
9
+ ASSEMBLYAI_MISTRAL7B = "assemblyai/mistral-7b"
10
+ ANTHROPIC_CLAUDE2_1 = "anthropic/claude-2-1"
11
+ end
12
12
  end
13
13
  end
@@ -6,15 +6,6 @@ module AssemblyAI
6
6
  class Lemur
7
7
  # Any context about the transcripts you wish to provide. This can be a string or any object.
8
8
  class LemurQuestionContext
9
- attr_reader :member
10
- alias kind_of? is_a?
11
- # @param member [Object]
12
- # @return [Lemur::LemurQuestionContext]
13
- def initialize(member:)
14
- # @type [Object]
15
- @member = member
16
- end
17
-
18
9
  # Deserialize a JSON object to an instance of LemurQuestionContext
19
10
  #
20
11
  # @param json_object [JSON]
@@ -23,26 +14,17 @@ module AssemblyAI
23
14
  struct = JSON.parse(json_object, object_class: OpenStruct)
24
15
  begin
25
16
  struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.")
26
- member = json_object
27
- return new(member: member)
17
+ return json_object
28
18
  rescue StandardError
29
19
  # noop
30
20
  end
31
21
  begin
32
22
  struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.")
33
- member = json_object
34
- return new(member: member)
23
+ return json_object
35
24
  rescue StandardError
36
25
  # noop
37
26
  end
38
- new(member: struct)
39
- end
40
-
41
- # For Union Types, to_json functionality is delegated to the wrapped member.
42
- #
43
- # @return [JSON]
44
- def to_json(*_args)
45
- @member.to_json
27
+ struct
46
28
  end
47
29
 
48
30
  # 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,14 +44,6 @@ module AssemblyAI
62
44
  end
63
45
  raise("Passed value matched no type within the union, validation failed.")
64
46
  end
65
-
66
- # For Union Types, is_a? functionality is delegated to the wrapped member.
67
- #
68
- # @param obj [Object]
69
- # @return [Boolean]
70
- def is_a?(obj)
71
- @member.is_a?(obj)
72
- end
73
47
  end
74
48
  end
75
49
  end
@@ -2,7 +2,10 @@
2
2
 
3
3
  module AssemblyAI
4
4
  class Realtime
5
- # @type [AUDIO_ENCODING]
6
- AUDIO_ENCODING = { pcm_s16le: "pcm_s16le", pcm_mulaw: "pcm_mulaw" }.freeze
5
+ # The encoding of the audio data
6
+ class AudioEncoding
7
+ PCM_S16LE = "pcm_s16le"
8
+ PCM_MULAW = "pcm_mulaw"
9
+ end
7
10
  end
8
11
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module AssemblyAI
6
+ class Realtime
7
+ # Configure the threshold for how long to wait before ending an utterance. Default is 700ms.
8
+ class ConfigureEndUtteranceSilenceThreshold
9
+ attr_reader :end_utterance_silence_threshold, :additional_properties
10
+
11
+ # @param end_utterance_silence_threshold [Integer] The duration threshold in milliseconds
12
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
13
+ # @return [Realtime::ConfigureEndUtteranceSilenceThreshold]
14
+ def initialize(end_utterance_silence_threshold:, additional_properties: nil)
15
+ # @type [Integer] The duration threshold in milliseconds
16
+ @end_utterance_silence_threshold = end_utterance_silence_threshold
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 ConfigureEndUtteranceSilenceThreshold
22
+ #
23
+ # @param json_object [JSON]
24
+ # @return [Realtime::ConfigureEndUtteranceSilenceThreshold]
25
+ def self.from_json(json_object:)
26
+ struct = JSON.parse(json_object, object_class: OpenStruct)
27
+ JSON.parse(json_object)
28
+ end_utterance_silence_threshold = struct.end_utterance_silence_threshold
29
+ new(end_utterance_silence_threshold: end_utterance_silence_threshold, additional_properties: struct)
30
+ end
31
+
32
+ # Serialize an instance of ConfigureEndUtteranceSilenceThreshold to a JSON object
33
+ #
34
+ # @return [JSON]
35
+ def to_json(*_args)
36
+ { "end_utterance_silence_threshold": @end_utterance_silence_threshold }.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.end_utterance_silence_threshold.is_a?(Integer) != false || raise("Passed value for field obj.end_utterance_silence_threshold is not the expected type, validation failed.")
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module AssemblyAI
6
+ class Realtime
7
+ # Manually end an utterance
8
+ class ForceEndUtterance
9
+ attr_reader :force_end_utterance, :additional_properties
10
+
11
+ # @param force_end_utterance [Boolean] A boolean value to communicate that you wish to force the end of the utterance
12
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
13
+ # @return [Realtime::ForceEndUtterance]
14
+ def initialize(force_end_utterance:, additional_properties: nil)
15
+ # @type [Boolean] A boolean value to communicate that you wish to force the end of the utterance
16
+ @force_end_utterance = force_end_utterance
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 ForceEndUtterance
22
+ #
23
+ # @param json_object [JSON]
24
+ # @return [Realtime::ForceEndUtterance]
25
+ def self.from_json(json_object:)
26
+ struct = JSON.parse(json_object, object_class: OpenStruct)
27
+ JSON.parse(json_object)
28
+ force_end_utterance = struct.force_end_utterance
29
+ new(force_end_utterance: force_end_utterance, additional_properties: struct)
30
+ end
31
+
32
+ # Serialize an instance of ForceEndUtterance to a JSON object
33
+ #
34
+ # @return [JSON]
35
+ def to_json(*_args)
36
+ { "force_end_utterance": @force_end_utterance }.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.force_end_utterance.is_a?(Boolean) != false || raise("Passed value for field obj.force_end_utterance is not the expected type, validation failed.")
45
+ end
46
+ end
47
+ end
48
+ end
@@ -2,12 +2,11 @@
2
2
 
3
3
  module AssemblyAI
4
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
5
+ class MessageType
6
+ SESSION_BEGINS = "SessionBegins"
7
+ PARTIAL_TRANSCRIPT = "PartialTranscript"
8
+ FINAL_TRANSCRIPT = "FinalTranscript"
9
+ SESSION_TERMINATED = "SessionTerminated"
10
+ end
12
11
  end
13
12
  end
@@ -8,11 +8,11 @@ module AssemblyAI
8
8
  class RealtimeBaseMessage
9
9
  attr_reader :message_type, :additional_properties
10
10
 
11
- # @param message_type [MESSAGE_TYPE] Describes the type of the message
11
+ # @param message_type [Realtime::MessageType] Describes the type of the message
12
12
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
13
13
  # @return [Realtime::RealtimeBaseMessage]
14
14
  def initialize(message_type:, additional_properties: nil)
15
- # @type [MESSAGE_TYPE] Describes the type of the message
15
+ # @type [Realtime::MessageType] Describes the type of the message
16
16
  @message_type = message_type
17
17
  # @type [OpenStruct] Additional properties unmapped to the current class definition
18
18
  @additional_properties = additional_properties
@@ -24,8 +24,8 @@ module AssemblyAI
24
24
  # @return [Realtime::RealtimeBaseMessage]
25
25
  def self.from_json(json_object:)
26
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"]
27
+ JSON.parse(json_object)
28
+ message_type = struct.message_type
29
29
  new(message_type: message_type, additional_properties: struct)
30
30
  end
31
31
 
@@ -33,7 +33,7 @@ module AssemblyAI
33
33
  #
34
34
  # @return [JSON]
35
35
  def to_json(*_args)
36
- { "message_type": Realtime::MESSAGE_TYPE[@message_type] || @message_type }.to_json
36
+ { "message_type": @message_type }.to_json
37
37
  end
38
38
 
39
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.
@@ -41,7 +41,7 @@ module AssemblyAI
41
41
  # @param obj [Object]
42
42
  # @return [Void]
43
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.")
44
+ obj.message_type.is_a?(Realtime::MessageType) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
45
45
  end
46
46
  end
47
47
  end
@@ -10,15 +10,6 @@ require_relative "realtime_error"
10
10
  module AssemblyAI
11
11
  class Realtime
12
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
13
  # Deserialize a JSON object to an instance of RealtimeMessage
23
14
  #
24
15
  # @param json_object [JSON]
@@ -27,47 +18,35 @@ module AssemblyAI
27
18
  struct = JSON.parse(json_object, object_class: OpenStruct)
28
19
  begin
29
20
  Realtime::SessionBegins.validate_raw(obj: struct)
30
- member = Realtime::SessionBegins.from_json(json_object: json_object)
31
- return new(member: member)
21
+ return Realtime::SessionBegins.from_json(json_object: json_object)
32
22
  rescue StandardError
33
23
  # noop
34
24
  end
35
25
  begin
36
26
  Realtime::PartialTranscript.validate_raw(obj: struct)
37
- member = Realtime::PartialTranscript.from_json(json_object: json_object)
38
- return new(member: member)
27
+ return Realtime::PartialTranscript.from_json(json_object: json_object)
39
28
  rescue StandardError
40
29
  # noop
41
30
  end
42
31
  begin
43
32
  Realtime::FinalTranscript.validate_raw(obj: struct)
44
- member = Realtime::FinalTranscript.from_json(json_object: json_object)
45
- return new(member: member)
33
+ return Realtime::FinalTranscript.from_json(json_object: json_object)
46
34
  rescue StandardError
47
35
  # noop
48
36
  end
49
37
  begin
50
38
  Realtime::SessionTerminated.validate_raw(obj: struct)
51
- member = Realtime::SessionTerminated.from_json(json_object: json_object)
52
- return new(member: member)
39
+ return Realtime::SessionTerminated.from_json(json_object: json_object)
53
40
  rescue StandardError
54
41
  # noop
55
42
  end
56
43
  begin
57
44
  Realtime::RealtimeError.validate_raw(obj: struct)
58
- member = Realtime::RealtimeError.from_json(json_object: json_object)
59
- return new(member: member)
45
+ return Realtime::RealtimeError.from_json(json_object: json_object)
60
46
  rescue StandardError
61
47
  # noop
62
48
  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
49
+ struct
71
50
  end
72
51
 
73
52
  # 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.
@@ -102,14 +81,6 @@ module AssemblyAI
102
81
  end
103
82
  raise("Passed value matched no type within the union, validation failed.")
104
83
  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
84
  end
114
85
  end
115
86
  end
@@ -7,15 +7,6 @@ require_relative "final_transcript"
7
7
  module AssemblyAI
8
8
  class Realtime
9
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
10
  # Deserialize a JSON object to an instance of RealtimeTranscript
20
11
  #
21
12
  # @param json_object [JSON]
@@ -24,26 +15,17 @@ module AssemblyAI
24
15
  struct = JSON.parse(json_object, object_class: OpenStruct)
25
16
  begin
26
17
  Realtime::PartialTranscript.validate_raw(obj: struct)
27
- member = Realtime::PartialTranscript.from_json(json_object: json_object)
28
- return new(member: member)
18
+ return Realtime::PartialTranscript.from_json(json_object: json_object)
29
19
  rescue StandardError
30
20
  # noop
31
21
  end
32
22
  begin
33
23
  Realtime::FinalTranscript.validate_raw(obj: struct)
34
- member = Realtime::FinalTranscript.from_json(json_object: json_object)
35
- return new(member: member)
24
+ return Realtime::FinalTranscript.from_json(json_object: json_object)
36
25
  rescue StandardError
37
26
  # noop
38
27
  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
28
+ struct
47
29
  end
48
30
 
49
31
  # 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.
@@ -63,14 +45,6 @@ module AssemblyAI
63
45
  end
64
46
  raise("Passed value matched no type within the union, validation failed.")
65
47
  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
48
  end
75
49
  end
76
50
  end
@@ -2,7 +2,9 @@
2
2
 
3
3
  module AssemblyAI
4
4
  class Realtime
5
- # @type [REALTIME_TRANSCRIPT_TYPE]
6
- REALTIME_TRANSCRIPT_TYPE = { partial_transcript: "PartialTranscript", final_transcript: "FinalTranscript" }.freeze
5
+ class RealtimeTranscriptType
6
+ PARTIAL_TRANSCRIPT = "PartialTranscript"
7
+ FINAL_TRANSCRIPT = "FinalTranscript"
8
+ end
7
9
  end
8
10
  end