assemblyai 1.0.0.pre.beta.7 → 1.0.0.pre.beta.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) 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 +260 -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 -55
  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 -32
  10. data/lib/assemblyai/lemur/types/lemur_question_answer.rb +28 -14
  11. data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +29 -15
  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 +73 -42
  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 +63 -35
  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 +32 -15
  29. data/lib/assemblyai/realtime/types/session_information.rb +69 -0
  30. data/lib/assemblyai/realtime/types/session_terminated.rb +21 -12
  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/entity_type.rb +15 -0
  47. data/lib/assemblyai/transcripts/types/page_details.rb +62 -36
  48. data/lib/assemblyai/transcripts/types/paragraphs_response.rb +37 -19
  49. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +4 -1
  50. data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +29 -15
  51. data/lib/assemblyai/transcripts/types/sentences_response.rb +37 -19
  52. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +63 -36
  53. data/lib/assemblyai/transcripts/types/severity_score_summary.rb +32 -16
  54. data/lib/assemblyai/transcripts/types/speech_model.rb +1 -0
  55. data/lib/assemblyai/transcripts/types/substitution_policy.rb +3 -1
  56. data/lib/assemblyai/transcripts/types/timestamp.rb +28 -14
  57. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +39 -20
  58. data/lib/assemblyai/transcripts/types/topic_detection_result.rb +40 -21
  59. data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +31 -15
  60. data/lib/assemblyai/transcripts/types/transcript.rb +513 -295
  61. data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +30 -15
  62. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +87 -4
  63. data/lib/assemblyai/transcripts/types/transcript_list.rb +33 -17
  64. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +60 -35
  65. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +338 -196
  66. data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +61 -34
  67. data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +30 -16
  68. data/lib/assemblyai/transcripts/types/transcript_sentence.rb +61 -34
  69. data/lib/assemblyai/transcripts/types/transcript_status.rb +2 -1
  70. data/lib/assemblyai/transcripts/types/transcript_utterance.rb +55 -32
  71. data/lib/assemblyai/transcripts/types/transcript_word.rb +55 -24
  72. data/lib/assemblyai/transcripts/types/word_search_match.rb +40 -20
  73. data/lib/assemblyai/transcripts/types/word_search_response.rb +36 -17
  74. data/lib/assemblyai/types/error.rb +32 -16
  75. data/lib/requests.rb +80 -34
  76. data/lib/types_export.rb +4 -3
  77. metadata +6 -5
  78. data/lib/assemblyai/realtime/types/audio_data.rb +0 -7
  79. data/lib/assemblyai/realtime/types/receive_message.rb +0 -87
@@ -1,50 +1,67 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "date"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Realtime
8
9
  class SessionBegins
9
- attr_reader :message_type, :session_id, :expires_at, :additional_properties
10
+ # @return [String] Describes the type of the message
11
+ attr_reader :message_type
12
+ # @return [String] Unique identifier for the established session
13
+ attr_reader :session_id
14
+ # @return [DateTime] Timestamp when this session will expire
15
+ attr_reader :expires_at
16
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
17
+ attr_reader :additional_properties
18
+ # @return [Object]
19
+ attr_reader :_field_set
20
+ protected :_field_set
10
21
 
11
- # @param message_type [String]
22
+ OMIT = Object.new
23
+
24
+ # @param message_type [String] Describes the type of the message
12
25
  # @param session_id [String] Unique identifier for the established session
13
26
  # @param expires_at [DateTime] Timestamp when this session will expire
14
27
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
15
- # @return [Realtime::SessionBegins]
28
+ # @return [AssemblyAI::Realtime::SessionBegins]
16
29
  def initialize(message_type:, session_id:, expires_at:, additional_properties: nil)
17
- # @type [String]
18
30
  @message_type = message_type
19
- # @type [String] Unique identifier for the established session
20
31
  @session_id = session_id
21
- # @type [DateTime] Timestamp when this session will expire
22
32
  @expires_at = expires_at
23
- # @type [OpenStruct] Additional properties unmapped to the current class definition
24
33
  @additional_properties = additional_properties
34
+ @_field_set = { "message_type": message_type, "session_id": session_id, "expires_at": expires_at }
25
35
  end
26
36
 
27
37
  # Deserialize a JSON object to an instance of SessionBegins
28
38
  #
29
- # @param json_object [JSON]
30
- # @return [Realtime::SessionBegins]
39
+ # @param json_object [String]
40
+ # @return [AssemblyAI::Realtime::SessionBegins]
31
41
  def self.from_json(json_object:)
32
42
  struct = JSON.parse(json_object, object_class: OpenStruct)
33
43
  parsed_json = JSON.parse(json_object)
34
- message_type = struct.message_type
35
- session_id = struct.session_id
44
+ message_type = struct["message_type"]
45
+ session_id = struct["session_id"]
36
46
  expires_at = (DateTime.parse(parsed_json["expires_at"]) unless parsed_json["expires_at"].nil?)
37
- new(message_type: message_type, session_id: session_id, expires_at: expires_at, additional_properties: struct)
47
+ new(
48
+ message_type: message_type,
49
+ session_id: session_id,
50
+ expires_at: expires_at,
51
+ additional_properties: struct
52
+ )
38
53
  end
39
54
 
40
55
  # Serialize an instance of SessionBegins to a JSON object
41
56
  #
42
- # @return [JSON]
57
+ # @return [String]
43
58
  def to_json(*_args)
44
- { "message_type": @message_type, "session_id": @session_id, "expires_at": @expires_at }.to_json
59
+ @_field_set&.to_json
45
60
  end
46
61
 
47
- # 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
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
63
+ # hash and check each fields type against the current object's property
64
+ # definitions.
48
65
  #
49
66
  # @param obj [Object]
50
67
  # @return [Void]
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module AssemblyAI
7
+ class Realtime
8
+ # Information about the session that is concluding.
9
+ # This message is sent at the end of the session, before the SessionTerminated
10
+ # message.
11
+ class SessionInformation
12
+ # @return [String] Describes the type of the message
13
+ attr_reader :message_type
14
+ # @return [Float] The total duration of the audio in seconds
15
+ attr_reader :audio_duration_seconds
16
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
17
+ attr_reader :additional_properties
18
+ # @return [Object]
19
+ attr_reader :_field_set
20
+ protected :_field_set
21
+
22
+ OMIT = Object.new
23
+
24
+ # @param message_type [String] Describes the type of the message
25
+ # @param audio_duration_seconds [Float] The total duration of the audio in seconds
26
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
27
+ # @return [AssemblyAI::Realtime::SessionInformation]
28
+ def initialize(message_type:, audio_duration_seconds:, additional_properties: nil)
29
+ @message_type = message_type
30
+ @audio_duration_seconds = audio_duration_seconds
31
+ @additional_properties = additional_properties
32
+ @_field_set = { "message_type": message_type, "audio_duration_seconds": audio_duration_seconds }
33
+ end
34
+
35
+ # Deserialize a JSON object to an instance of SessionInformation
36
+ #
37
+ # @param json_object [String]
38
+ # @return [AssemblyAI::Realtime::SessionInformation]
39
+ def self.from_json(json_object:)
40
+ struct = JSON.parse(json_object, object_class: OpenStruct)
41
+ message_type = struct["message_type"]
42
+ audio_duration_seconds = struct["audio_duration_seconds"]
43
+ new(
44
+ message_type: message_type,
45
+ audio_duration_seconds: audio_duration_seconds,
46
+ additional_properties: struct
47
+ )
48
+ end
49
+
50
+ # Serialize an instance of SessionInformation to a JSON object
51
+ #
52
+ # @return [String]
53
+ def to_json(*_args)
54
+ @_field_set&.to_json
55
+ end
56
+
57
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
58
+ # hash and check each fields type against the current object's property
59
+ # definitions.
60
+ #
61
+ # @param obj [Object]
62
+ # @return [Void]
63
+ def self.validate_raw(obj:)
64
+ obj.message_type.is_a?(String) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
65
+ obj.audio_duration_seconds.is_a?(Float) != false || raise("Passed value for field obj.audio_duration_seconds is not the expected type, validation failed.")
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,41 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Realtime
7
8
  class SessionTerminated
8
- attr_reader :message_type, :additional_properties
9
+ # @return [String] Describes the type of the message
10
+ attr_reader :message_type
11
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
12
+ attr_reader :additional_properties
13
+ # @return [Object]
14
+ attr_reader :_field_set
15
+ protected :_field_set
9
16
 
10
- # @param message_type [String]
17
+ OMIT = Object.new
18
+
19
+ # @param message_type [String] Describes the type of the message
11
20
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
12
- # @return [Realtime::SessionTerminated]
21
+ # @return [AssemblyAI::Realtime::SessionTerminated]
13
22
  def initialize(message_type:, additional_properties: nil)
14
- # @type [String]
15
23
  @message_type = message_type
16
- # @type [OpenStruct] Additional properties unmapped to the current class definition
17
24
  @additional_properties = additional_properties
25
+ @_field_set = { "message_type": message_type }
18
26
  end
19
27
 
20
28
  # Deserialize a JSON object to an instance of SessionTerminated
21
29
  #
22
- # @param json_object [JSON]
23
- # @return [Realtime::SessionTerminated]
30
+ # @param json_object [String]
31
+ # @return [AssemblyAI::Realtime::SessionTerminated]
24
32
  def self.from_json(json_object:)
25
33
  struct = JSON.parse(json_object, object_class: OpenStruct)
26
- JSON.parse(json_object)
27
- message_type = struct.message_type
34
+ message_type = struct["message_type"]
28
35
  new(message_type: message_type, additional_properties: struct)
29
36
  end
30
37
 
31
38
  # Serialize an instance of SessionTerminated to a JSON object
32
39
  #
33
- # @return [JSON]
40
+ # @return [String]
34
41
  def to_json(*_args)
35
- { "message_type": @message_type }.to_json
42
+ @_field_set&.to_json
36
43
  end
37
44
 
38
- # 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.
45
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
46
+ # hash and check each fields type against the current object's property
47
+ # definitions.
39
48
  #
40
49
  # @param obj [Object]
41
50
  # @return [Void]
@@ -1,41 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Realtime
7
8
  class TerminateSession
8
- attr_reader :terminate_session, :additional_properties
9
+ # @return [Boolean] Set to true to end your streaming session forever
10
+ attr_reader :terminate_session
11
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
12
+ attr_reader :additional_properties
13
+ # @return [Object]
14
+ attr_reader :_field_set
15
+ protected :_field_set
16
+
17
+ OMIT = Object.new
9
18
 
10
19
  # @param terminate_session [Boolean] Set to true to end your streaming session forever
11
20
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
12
- # @return [Realtime::TerminateSession]
21
+ # @return [AssemblyAI::Realtime::TerminateSession]
13
22
  def initialize(terminate_session:, additional_properties: nil)
14
- # @type [Boolean] Set to true to end your streaming session forever
15
23
  @terminate_session = terminate_session
16
- # @type [OpenStruct] Additional properties unmapped to the current class definition
17
24
  @additional_properties = additional_properties
25
+ @_field_set = { "terminate_session": terminate_session }
18
26
  end
19
27
 
20
28
  # Deserialize a JSON object to an instance of TerminateSession
21
29
  #
22
- # @param json_object [JSON]
23
- # @return [Realtime::TerminateSession]
30
+ # @param json_object [String]
31
+ # @return [AssemblyAI::Realtime::TerminateSession]
24
32
  def self.from_json(json_object:)
25
33
  struct = JSON.parse(json_object, object_class: OpenStruct)
26
- JSON.parse(json_object)
27
- terminate_session = struct.terminate_session
34
+ terminate_session = struct["terminate_session"]
28
35
  new(terminate_session: terminate_session, additional_properties: struct)
29
36
  end
30
37
 
31
38
  # Serialize an instance of TerminateSession to a JSON object
32
39
  #
33
- # @return [JSON]
40
+ # @return [String]
34
41
  def to_json(*_args)
35
- { "terminate_session": @terminate_session }.to_json
42
+ @_field_set&.to_json
36
43
  end
37
44
 
38
- # 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.
45
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
46
+ # hash and check each fields type against the current object's property
47
+ # definitions.
39
48
  #
40
49
  # @param obj [Object]
41
50
  # @return [Void]
@@ -1,53 +1,71 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Realtime
7
8
  class Word
8
- attr_reader :start, :end_, :confidence, :text, :additional_properties
9
+ # @return [Integer] Start time of the word in milliseconds
10
+ attr_reader :start
11
+ # @return [Integer] End time of the word in milliseconds
12
+ attr_reader :end_
13
+ # @return [Float] Confidence score of the word
14
+ attr_reader :confidence
15
+ # @return [String] The word itself
16
+ attr_reader :text
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
22
+
23
+ OMIT = Object.new
9
24
 
10
25
  # @param start [Integer] Start time of the word in milliseconds
11
26
  # @param end_ [Integer] End time of the word in milliseconds
12
27
  # @param confidence [Float] Confidence score of the word
13
28
  # @param text [String] The word itself
14
29
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
15
- # @return [Realtime::Word]
30
+ # @return [AssemblyAI::Realtime::Word]
16
31
  def initialize(start:, end_:, confidence:, text:, additional_properties: nil)
17
- # @type [Integer] Start time of the word in milliseconds
18
32
  @start = start
19
- # @type [Integer] End time of the word in milliseconds
20
33
  @end_ = end_
21
- # @type [Float] Confidence score of the word
22
34
  @confidence = confidence
23
- # @type [String] The word itself
24
35
  @text = text
25
- # @type [OpenStruct] Additional properties unmapped to the current class definition
26
36
  @additional_properties = additional_properties
37
+ @_field_set = { "start": start, "end": end_, "confidence": confidence, "text": text }
27
38
  end
28
39
 
29
40
  # Deserialize a JSON object to an instance of Word
30
41
  #
31
- # @param json_object [JSON]
32
- # @return [Realtime::Word]
42
+ # @param json_object [String]
43
+ # @return [AssemblyAI::Realtime::Word]
33
44
  def self.from_json(json_object:)
34
45
  struct = JSON.parse(json_object, object_class: OpenStruct)
35
- JSON.parse(json_object)
36
- start = struct.start
37
- end_ = struct.end
38
- confidence = struct.confidence
39
- text = struct.text
40
- new(start: start, end_: end_, confidence: confidence, text: text, additional_properties: struct)
46
+ start = struct["start"]
47
+ end_ = struct["end"]
48
+ confidence = struct["confidence"]
49
+ text = struct["text"]
50
+ new(
51
+ start: start,
52
+ end_: end_,
53
+ confidence: confidence,
54
+ text: text,
55
+ additional_properties: struct
56
+ )
41
57
  end
42
58
 
43
59
  # Serialize an instance of Word to a JSON object
44
60
  #
45
- # @return [JSON]
61
+ # @return [String]
46
62
  def to_json(*_args)
47
- { "start": @start, "end": @end_, "confidence": @confidence, "text": @text }.to_json
63
+ @_field_set&.to_json
48
64
  end
49
65
 
50
- # 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.
66
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
67
+ # hash and check each fields type against the current object's property
68
+ # definitions.
51
69
  #
52
70
  # @param obj [Object]
53
71
  # @return [Void]
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "../../realtime/types/session_begins"
5
+ require_relative "../../realtime/types/partial_transcript"
6
+ require_relative "../../realtime/types/final_transcript"
7
+ require_relative "../../realtime/types/session_information"
8
+ require_relative "../../realtime/types/session_terminated"
9
+ require_relative "../../realtime/types/realtime_error"
10
+
11
+ module AssemblyAI
12
+ class Streaming
13
+ # Receive messages from the WebSocket
14
+ class ReceiveMessage
15
+ # Deserialize a JSON object to an instance of ReceiveMessage
16
+ #
17
+ # @param json_object [String]
18
+ # @return [AssemblyAI::Streaming::ReceiveMessage]
19
+ def self.from_json(json_object:)
20
+ struct = JSON.parse(json_object, object_class: OpenStruct)
21
+ begin
22
+ AssemblyAI::Realtime::SessionBegins.validate_raw(obj: struct)
23
+ return AssemblyAI::Realtime::SessionBegins.from_json(json_object: json_object) unless json_object.nil?
24
+
25
+ return nil
26
+ rescue StandardError
27
+ # noop
28
+ end
29
+ begin
30
+ AssemblyAI::Realtime::PartialTranscript.validate_raw(obj: struct)
31
+ return AssemblyAI::Realtime::PartialTranscript.from_json(json_object: json_object) unless json_object.nil?
32
+
33
+ return nil
34
+ rescue StandardError
35
+ # noop
36
+ end
37
+ begin
38
+ AssemblyAI::Realtime::FinalTranscript.validate_raw(obj: struct)
39
+ return AssemblyAI::Realtime::FinalTranscript.from_json(json_object: json_object) unless json_object.nil?
40
+
41
+ return nil
42
+ rescue StandardError
43
+ # noop
44
+ end
45
+ begin
46
+ AssemblyAI::Realtime::SessionInformation.validate_raw(obj: struct)
47
+ return AssemblyAI::Realtime::SessionInformation.from_json(json_object: json_object) unless json_object.nil?
48
+
49
+ return nil
50
+ rescue StandardError
51
+ # noop
52
+ end
53
+ begin
54
+ AssemblyAI::Realtime::SessionTerminated.validate_raw(obj: struct)
55
+ return AssemblyAI::Realtime::SessionTerminated.from_json(json_object: json_object) unless json_object.nil?
56
+
57
+ return nil
58
+ rescue StandardError
59
+ # noop
60
+ end
61
+ begin
62
+ AssemblyAI::Realtime::RealtimeError.validate_raw(obj: struct)
63
+ return AssemblyAI::Realtime::RealtimeError.from_json(json_object: json_object) unless json_object.nil?
64
+
65
+ return nil
66
+ rescue StandardError
67
+ # noop
68
+ end
69
+ struct
70
+ end
71
+
72
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
73
+ # hash and check each fields type against the current object's property
74
+ # definitions.
75
+ #
76
+ # @param obj [Object]
77
+ # @return [Void]
78
+ def self.validate_raw(obj:)
79
+ begin
80
+ return AssemblyAI::Realtime::SessionBegins.validate_raw(obj: obj)
81
+ rescue StandardError
82
+ # noop
83
+ end
84
+ begin
85
+ return AssemblyAI::Realtime::PartialTranscript.validate_raw(obj: obj)
86
+ rescue StandardError
87
+ # noop
88
+ end
89
+ begin
90
+ return AssemblyAI::Realtime::FinalTranscript.validate_raw(obj: obj)
91
+ rescue StandardError
92
+ # noop
93
+ end
94
+ begin
95
+ return AssemblyAI::Realtime::SessionInformation.validate_raw(obj: obj)
96
+ rescue StandardError
97
+ # noop
98
+ end
99
+ begin
100
+ return AssemblyAI::Realtime::SessionTerminated.validate_raw(obj: obj)
101
+ rescue StandardError
102
+ # noop
103
+ end
104
+ begin
105
+ return AssemblyAI::Realtime::RealtimeError.validate_raw(obj: obj)
106
+ rescue StandardError
107
+ # noop
108
+ end
109
+ raise("Passed value matched no type within the union, validation failed.")
110
+ end
111
+ end
112
+ end
113
+ end
@@ -6,43 +6,55 @@ require_relative "../../realtime/types/force_end_utterance"
6
6
  require_relative "../../realtime/types/configure_end_utterance_silence_threshold"
7
7
 
8
8
  module AssemblyAI
9
- class Realtime
9
+ class Streaming
10
10
  # Send messages to the WebSocket
11
11
  class SendMessage
12
12
  # Deserialize a JSON object to an instance of SendMessage
13
13
  #
14
- # @param json_object [JSON]
15
- # @return [Realtime::SendMessage]
14
+ # @param json_object [String]
15
+ # @return [AssemblyAI::Streaming::SendMessage]
16
16
  def self.from_json(json_object:)
17
17
  struct = JSON.parse(json_object, object_class: OpenStruct)
18
18
  begin
19
19
  struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.")
20
- return json_object
20
+ return json_object unless json_object.nil?
21
+
22
+ return nil
21
23
  rescue StandardError
22
24
  # noop
23
25
  end
24
26
  begin
25
- Realtime::TerminateSession.validate_raw(obj: struct)
26
- return Realtime::TerminateSession.from_json(json_object: json_object)
27
+ AssemblyAI::Realtime::TerminateSession.validate_raw(obj: struct)
28
+ return AssemblyAI::Realtime::TerminateSession.from_json(json_object: json_object) unless json_object.nil?
29
+
30
+ return nil
27
31
  rescue StandardError
28
32
  # noop
29
33
  end
30
34
  begin
31
- Realtime::ForceEndUtterance.validate_raw(obj: struct)
32
- return Realtime::ForceEndUtterance.from_json(json_object: json_object)
35
+ AssemblyAI::Realtime::ForceEndUtterance.validate_raw(obj: struct)
36
+ return AssemblyAI::Realtime::ForceEndUtterance.from_json(json_object: json_object) unless json_object.nil?
37
+
38
+ return nil
33
39
  rescue StandardError
34
40
  # noop
35
41
  end
36
42
  begin
37
- Realtime::ConfigureEndUtteranceSilenceThreshold.validate_raw(obj: struct)
38
- return Realtime::ConfigureEndUtteranceSilenceThreshold.from_json(json_object: json_object)
43
+ AssemblyAI::Realtime::ConfigureEndUtteranceSilenceThreshold.validate_raw(obj: struct)
44
+ unless json_object.nil?
45
+ return AssemblyAI::Realtime::ConfigureEndUtteranceSilenceThreshold.from_json(json_object: json_object)
46
+ end
47
+
48
+ return nil
39
49
  rescue StandardError
40
50
  # noop
41
51
  end
42
52
  struct
43
53
  end
44
54
 
45
- # 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.
55
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
56
+ # hash and check each fields type against the current object's property
57
+ # definitions.
46
58
  #
47
59
  # @param obj [Object]
48
60
  # @return [Void]
@@ -53,17 +65,17 @@ module AssemblyAI
53
65
  # noop
54
66
  end
55
67
  begin
56
- return Realtime::TerminateSession.validate_raw(obj: obj)
68
+ return AssemblyAI::Realtime::TerminateSession.validate_raw(obj: obj)
57
69
  rescue StandardError
58
70
  # noop
59
71
  end
60
72
  begin
61
- return Realtime::ForceEndUtterance.validate_raw(obj: obj)
73
+ return AssemblyAI::Realtime::ForceEndUtterance.validate_raw(obj: obj)
62
74
  rescue StandardError
63
75
  # noop
64
76
  end
65
77
  begin
66
- return Realtime::ConfigureEndUtteranceSilenceThreshold.validate_raw(obj: obj)
78
+ return AssemblyAI::Realtime::ConfigureEndUtteranceSilenceThreshold.validate_raw(obj: obj)
67
79
  rescue StandardError
68
80
  # noop
69
81
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AssemblyAI
4
+ class Streaming
5
+ # The encoding of the audio data
6
+ class Streaming
7
+ PCM_S16LE = "pcm_s16le"
8
+ PCM_MULAW = "pcm_mulaw"
9
+ end
10
+ end
11
+ end