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,54 +1,74 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "word_search_timestamp"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Transcripts
8
9
  class WordSearchMatch
9
- attr_reader :text, :count, :timestamps, :indexes, :additional_properties
10
+ # @return [String] The matched word
11
+ attr_reader :text
12
+ # @return [Integer] The total amount of times the word is in the transcript
13
+ attr_reader :count
14
+ # @return [Array<AssemblyAI::Transcripts::WORD_SEARCH_TIMESTAMP>] An array of timestamps
15
+ attr_reader :timestamps
16
+ # @return [Array<Integer>] An array of all index locations for that word within the `words` array of the
17
+ # completed transcript
18
+ attr_reader :indexes
19
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
20
+ attr_reader :additional_properties
21
+ # @return [Object]
22
+ attr_reader :_field_set
23
+ protected :_field_set
24
+
25
+ OMIT = Object.new
10
26
 
11
27
  # @param text [String] The matched word
12
28
  # @param count [Integer] The total amount of times the word is in the transcript
13
- # @param timestamps [Array<Transcripts::WORD_SEARCH_TIMESTAMP>] An array of timestamps
14
- # @param indexes [Array<Integer>] An array of all index locations for that word within the `words` array of the completed transcript
29
+ # @param timestamps [Array<AssemblyAI::Transcripts::WORD_SEARCH_TIMESTAMP>] An array of timestamps
30
+ # @param indexes [Array<Integer>] An array of all index locations for that word within the `words` array of the
31
+ # completed transcript
15
32
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
16
- # @return [Transcripts::WordSearchMatch]
33
+ # @return [AssemblyAI::Transcripts::WordSearchMatch]
17
34
  def initialize(text:, count:, timestamps:, indexes:, additional_properties: nil)
18
- # @type [String] The matched word
19
35
  @text = text
20
- # @type [Integer] The total amount of times the word is in the transcript
21
36
  @count = count
22
- # @type [Array<Transcripts::WORD_SEARCH_TIMESTAMP>] An array of timestamps
23
37
  @timestamps = timestamps
24
- # @type [Array<Integer>] An array of all index locations for that word within the `words` array of the completed transcript
25
38
  @indexes = indexes
26
- # @type [OpenStruct] Additional properties unmapped to the current class definition
27
39
  @additional_properties = additional_properties
40
+ @_field_set = { "text": text, "count": count, "timestamps": timestamps, "indexes": indexes }
28
41
  end
29
42
 
30
43
  # Deserialize a JSON object to an instance of WordSearchMatch
31
44
  #
32
- # @param json_object [JSON]
33
- # @return [Transcripts::WordSearchMatch]
45
+ # @param json_object [String]
46
+ # @return [AssemblyAI::Transcripts::WordSearchMatch]
34
47
  def self.from_json(json_object:)
35
48
  struct = JSON.parse(json_object, object_class: OpenStruct)
36
- JSON.parse(json_object)
37
- text = struct.text
38
- count = struct.count
39
- timestamps = struct.timestamps
40
- indexes = struct.indexes
41
- new(text: text, count: count, timestamps: timestamps, indexes: indexes, additional_properties: struct)
49
+ text = struct["text"]
50
+ count = struct["count"]
51
+ timestamps = struct["timestamps"]
52
+ indexes = struct["indexes"]
53
+ new(
54
+ text: text,
55
+ count: count,
56
+ timestamps: timestamps,
57
+ indexes: indexes,
58
+ additional_properties: struct
59
+ )
42
60
  end
43
61
 
44
62
  # Serialize an instance of WordSearchMatch to a JSON object
45
63
  #
46
- # @return [JSON]
64
+ # @return [String]
47
65
  def to_json(*_args)
48
- { "text": @text, "count": @count, "timestamps": @timestamps, "indexes": @indexes }.to_json
66
+ @_field_set&.to_json
49
67
  end
50
68
 
51
- # 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.
69
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
70
+ # hash and check each fields type against the current object's property
71
+ # definitions.
52
72
  #
53
73
  # @param obj [Object]
54
74
  # @return [Void]
@@ -1,53 +1,72 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "word_search_match"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Transcripts
8
9
  class WordSearchResponse
9
- attr_reader :id, :total_count, :matches, :additional_properties
10
+ # @return [String] The ID of the transcript
11
+ attr_reader :id
12
+ # @return [Integer] The total count of all matched instances. For e.g., word 1 matched 2 times, and
13
+ # word 2 matched 3 times, `total_count` will equal 5.
14
+ attr_reader :total_count
15
+ # @return [Array<AssemblyAI::Transcripts::WordSearchMatch>] The matches of the search
16
+ attr_reader :matches
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
10
24
 
11
25
  # @param id [String] The ID of the transcript
12
- # @param total_count [Integer] The total count of all matched instances. For e.g., word 1 matched 2 times, and word 2 matched 3 times, `total_count` will equal 5.
13
- # @param matches [Array<Transcripts::WordSearchMatch>] The matches of the search
26
+ # @param total_count [Integer] The total count of all matched instances. For e.g., word 1 matched 2 times, and
27
+ # word 2 matched 3 times, `total_count` will equal 5.
28
+ # @param matches [Array<AssemblyAI::Transcripts::WordSearchMatch>] The matches of the search
14
29
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
15
- # @return [Transcripts::WordSearchResponse]
30
+ # @return [AssemblyAI::Transcripts::WordSearchResponse]
16
31
  def initialize(id:, total_count:, matches:, additional_properties: nil)
17
- # @type [String] The ID of the transcript
18
32
  @id = id
19
- # @type [Integer] The total count of all matched instances. For e.g., word 1 matched 2 times, and word 2 matched 3 times, `total_count` will equal 5.
20
33
  @total_count = total_count
21
- # @type [Array<Transcripts::WordSearchMatch>] The matches of the search
22
34
  @matches = matches
23
- # @type [OpenStruct] Additional properties unmapped to the current class definition
24
35
  @additional_properties = additional_properties
36
+ @_field_set = { "id": id, "total_count": total_count, "matches": matches }
25
37
  end
26
38
 
27
39
  # Deserialize a JSON object to an instance of WordSearchResponse
28
40
  #
29
- # @param json_object [JSON]
30
- # @return [Transcripts::WordSearchResponse]
41
+ # @param json_object [String]
42
+ # @return [AssemblyAI::Transcripts::WordSearchResponse]
31
43
  def self.from_json(json_object:)
32
44
  struct = JSON.parse(json_object, object_class: OpenStruct)
33
45
  parsed_json = JSON.parse(json_object)
34
- id = struct.id
35
- total_count = struct.total_count
46
+ id = struct["id"]
47
+ total_count = struct["total_count"]
36
48
  matches = parsed_json["matches"]&.map do |v|
37
49
  v = v.to_json
38
- Transcripts::WordSearchMatch.from_json(json_object: v)
50
+ AssemblyAI::Transcripts::WordSearchMatch.from_json(json_object: v)
39
51
  end
40
- new(id: id, total_count: total_count, matches: matches, additional_properties: struct)
52
+ new(
53
+ id: id,
54
+ total_count: total_count,
55
+ matches: matches,
56
+ additional_properties: struct
57
+ )
41
58
  end
42
59
 
43
60
  # Serialize an instance of WordSearchResponse to a JSON object
44
61
  #
45
- # @return [JSON]
62
+ # @return [String]
46
63
  def to_json(*_args)
47
- { "id": @id, "total_count": @total_count, "matches": @matches }.to_json
64
+ @_field_set&.to_json
48
65
  end
49
66
 
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.
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.
51
70
  #
52
71
  # @param obj [Object]
53
72
  # @return [Void]
@@ -1,44 +1,60 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Error
7
- attr_reader :error, :status, :additional_properties
8
+ # @return [String] Error message
9
+ attr_reader :error
10
+ # @return [String]
11
+ attr_reader :status
12
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
13
+ attr_reader :additional_properties
14
+ # @return [Object]
15
+ attr_reader :_field_set
16
+ protected :_field_set
17
+
18
+ OMIT = Object.new
8
19
 
9
20
  # @param error [String] Error message
10
21
  # @param status [String]
11
22
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
12
- # @return [Error]
13
- def initialize(error:, status: nil, additional_properties: nil)
14
- # @type [String] Error message
23
+ # @return [AssemblyAI::Error]
24
+ def initialize(error:, status: OMIT, additional_properties: nil)
15
25
  @error = error
16
- # @type [String]
17
- @status = status
18
- # @type [OpenStruct] Additional properties unmapped to the current class definition
26
+ @status = status if status != OMIT
19
27
  @additional_properties = additional_properties
28
+ @_field_set = { "error": error, "status": status }.reject do |_k, v|
29
+ v == OMIT
30
+ end
20
31
  end
21
32
 
22
33
  # Deserialize a JSON object to an instance of Error
23
34
  #
24
- # @param json_object [JSON]
25
- # @return [Error]
35
+ # @param json_object [String]
36
+ # @return [AssemblyAI::Error]
26
37
  def self.from_json(json_object:)
27
38
  struct = JSON.parse(json_object, object_class: OpenStruct)
28
- JSON.parse(json_object)
29
- error = struct.error
30
- status = struct.status
31
- new(error: error, status: status, additional_properties: struct)
39
+ error = struct["error"]
40
+ status = struct["status"]
41
+ new(
42
+ error: error,
43
+ status: status,
44
+ additional_properties: struct
45
+ )
32
46
  end
33
47
 
34
48
  # Serialize an instance of Error to a JSON object
35
49
  #
36
- # @return [JSON]
50
+ # @return [String]
37
51
  def to_json(*_args)
38
- { "error": @error, "status": @status }.to_json
52
+ @_field_set&.to_json
39
53
  end
40
54
 
41
- # 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.
42
58
  #
43
59
  # @param obj [Object]
44
60
  # @return [Void]
data/lib/requests.rb CHANGED
@@ -7,49 +7,73 @@ require "async/http/faraday"
7
7
 
8
8
  module AssemblyAI
9
9
  class RequestClient
10
- attr_reader :headers, :base_url, :conn
10
+ # @return [Hash{String => String}]
11
+ attr_reader :headers
12
+ # @return [Faraday]
13
+ attr_reader :conn
14
+ # @return [String]
15
+ attr_reader :base_url
16
+ # @return [String]
17
+ attr_reader :default_environment
11
18
 
12
- # @param environment [Environment]
19
+ # @param environment [AssemblyAI::Environment]
20
+ # @param base_url [String]
13
21
  # @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
14
22
  # @param timeout_in_seconds [Long]
15
23
  # @param api_key [String]
16
- # @return [RequestClient]
17
- def initialize(api_key:, environment: Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil)
24
+ # @return [AssemblyAI::RequestClient]
25
+ def initialize(api_key:, environment: Environment::DEFAULT, base_url: nil, max_retries: nil,
26
+ timeout_in_seconds: nil)
18
27
  @default_environment = environment
19
- @base_url = environment
28
+ @base_url = environment || base_url
20
29
  @headers = {
21
30
  "X-Fern-Language": "Ruby",
22
31
  "X-Fern-SDK-Name": "assemblyai",
23
- "X-Fern-SDK-Version": "1.0.0-beta.7",
32
+ "X-Fern-SDK-Version": "1.0.0-beta.9",
24
33
  "Authorization": api_key.to_s
25
34
  }
26
- @conn = Faraday.new(@base_url, headers: @headers) do |faraday|
35
+ @conn = Faraday.new(headers: @headers) do |faraday|
27
36
  faraday.request :json
28
37
  faraday.response :raise_error, include_request: true
29
38
  faraday.request :retry, { max: max_retries } unless max_retries.nil?
30
39
  faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil?
31
40
  end
32
41
  end
42
+
43
+ # @param request_options [AssemblyAI::RequestOptions]
44
+ # @return [String]
45
+ def get_url(request_options: nil)
46
+ request_options&.base_url || @default_environment || @base_url
47
+ end
33
48
  end
34
49
 
35
50
  class AsyncRequestClient
36
- attr_reader :headers, :base_url, :conn
51
+ # @return [Hash{String => String}]
52
+ attr_reader :headers
53
+ # @return [Faraday]
54
+ attr_reader :conn
55
+ # @return [String]
56
+ attr_reader :base_url
57
+ # @return [String]
58
+ attr_reader :default_environment
37
59
 
38
- # @param environment [Environment]
60
+ # @param environment [AssemblyAI::Environment]
61
+ # @param base_url [String]
39
62
  # @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
40
63
  # @param timeout_in_seconds [Long]
41
64
  # @param api_key [String]
42
- # @return [AsyncRequestClient]
43
- def initialize(api_key:, environment: Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil)
65
+ # @return [AssemblyAI::AsyncRequestClient]
66
+ def initialize(api_key:, environment: Environment::DEFAULT, base_url: nil, max_retries: nil,
67
+ timeout_in_seconds: nil)
44
68
  @default_environment = environment
45
- @base_url = environment
69
+ @base_url = environment || base_url
46
70
  @headers = {
47
71
  "X-Fern-Language": "Ruby",
48
72
  "X-Fern-SDK-Name": "assemblyai",
49
- "X-Fern-SDK-Version": "1.0.0-beta.7",
73
+ "X-Fern-SDK-Version": "1.0.0-beta.9",
50
74
  "Authorization": api_key.to_s
51
75
  }
52
- @conn = Faraday.new(@base_url, headers: @headers) do |faraday|
76
+ @conn = Faraday.new(headers: @headers) do |faraday|
53
77
  faraday.request :json
54
78
  faraday.response :raise_error, include_request: true
55
79
  faraday.adapter :async_http
@@ -57,56 +81,78 @@ module AssemblyAI
57
81
  faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil?
58
82
  end
59
83
  end
84
+
85
+ # @param request_options [AssemblyAI::RequestOptions]
86
+ # @return [String]
87
+ def get_url(request_options: nil)
88
+ request_options&.base_url || @default_environment || @base_url
89
+ end
60
90
  end
61
91
 
62
- # Additional options for request-specific configuration when calling APIs via the SDK.
92
+ # Additional options for request-specific configuration when calling APIs via the
93
+ # SDK.
63
94
  class RequestOptions
64
- attr_reader :api_key, :additional_headers, :additional_query_parameters, :additional_body_parameters,
65
- :timeout_in_seconds
95
+ # @return [String]
96
+ attr_reader :base_url
97
+ # @return [String]
98
+ attr_reader :api_key
99
+ # @return [Hash{String => Object}]
100
+ attr_reader :additional_headers
101
+ # @return [Hash{String => Object}]
102
+ attr_reader :additional_query_parameters
103
+ # @return [Hash{String => Object}]
104
+ attr_reader :additional_body_parameters
105
+ # @return [Long]
106
+ attr_reader :timeout_in_seconds
66
107
 
108
+ # @param base_url [String]
67
109
  # @param api_key [String]
68
110
  # @param additional_headers [Hash{String => Object}]
69
111
  # @param additional_query_parameters [Hash{String => Object}]
70
112
  # @param additional_body_parameters [Hash{String => Object}]
71
113
  # @param timeout_in_seconds [Long]
72
- # @return [RequestOptions]
73
- def initialize(api_key: nil, additional_headers: nil, additional_query_parameters: nil,
114
+ # @return [AssemblyAI::RequestOptions]
115
+ def initialize(base_url: nil, api_key: nil, additional_headers: nil, additional_query_parameters: nil,
74
116
  additional_body_parameters: nil, timeout_in_seconds: nil)
75
- # @type [String]
117
+ @base_url = base_url
76
118
  @api_key = api_key
77
- # @type [Hash{String => Object}]
78
119
  @additional_headers = additional_headers
79
- # @type [Hash{String => Object}]
80
120
  @additional_query_parameters = additional_query_parameters
81
- # @type [Hash{String => Object}]
82
121
  @additional_body_parameters = additional_body_parameters
83
- # @type [Long]
84
122
  @timeout_in_seconds = timeout_in_seconds
85
123
  end
86
124
  end
87
125
 
88
- # Additional options for request-specific configuration when calling APIs via the SDK.
126
+ # Additional options for request-specific configuration when calling APIs via the
127
+ # SDK.
89
128
  class IdempotencyRequestOptions
90
- attr_reader :api_key, :additional_headers, :additional_query_parameters, :additional_body_parameters,
91
- :timeout_in_seconds
129
+ # @return [String]
130
+ attr_reader :base_url
131
+ # @return [String]
132
+ attr_reader :api_key
133
+ # @return [Hash{String => Object}]
134
+ attr_reader :additional_headers
135
+ # @return [Hash{String => Object}]
136
+ attr_reader :additional_query_parameters
137
+ # @return [Hash{String => Object}]
138
+ attr_reader :additional_body_parameters
139
+ # @return [Long]
140
+ attr_reader :timeout_in_seconds
92
141
 
142
+ # @param base_url [String]
93
143
  # @param api_key [String]
94
144
  # @param additional_headers [Hash{String => Object}]
95
145
  # @param additional_query_parameters [Hash{String => Object}]
96
146
  # @param additional_body_parameters [Hash{String => Object}]
97
147
  # @param timeout_in_seconds [Long]
98
- # @return [IdempotencyRequestOptions]
99
- def initialize(api_key: nil, additional_headers: nil, additional_query_parameters: nil,
148
+ # @return [AssemblyAI::IdempotencyRequestOptions]
149
+ def initialize(base_url: nil, api_key: nil, additional_headers: nil, additional_query_parameters: nil,
100
150
  additional_body_parameters: nil, timeout_in_seconds: nil)
101
- # @type [String]
151
+ @base_url = base_url
102
152
  @api_key = api_key
103
- # @type [Hash{String => Object}]
104
153
  @additional_headers = additional_headers
105
- # @type [Hash{String => Object}]
106
154
  @additional_query_parameters = additional_query_parameters
107
- # @type [Hash{String => Object}]
108
155
  @additional_body_parameters = additional_body_parameters
109
- # @type [Long]
110
156
  @timeout_in_seconds = timeout_in_seconds
111
157
  end
112
158
  end
data/lib/types_export.rb CHANGED
@@ -50,6 +50,7 @@ require_relative "assemblyai/realtime/types/realtime_base_message"
50
50
  require_relative "assemblyai/realtime/types/session_begins"
51
51
  require_relative "assemblyai/realtime/types/partial_transcript"
52
52
  require_relative "assemblyai/realtime/types/final_transcript"
53
+ require_relative "assemblyai/realtime/types/session_information"
53
54
  require_relative "assemblyai/realtime/types/session_terminated"
54
55
  require_relative "assemblyai/realtime/types/realtime_error"
55
56
  require_relative "assemblyai/realtime/types/realtime_message"
@@ -58,14 +59,11 @@ require_relative "assemblyai/realtime/types/realtime_transcript_type"
58
59
  require_relative "assemblyai/realtime/types/realtime_transcript"
59
60
  require_relative "assemblyai/realtime/types/realtime_base_transcript"
60
61
  require_relative "assemblyai/realtime/types/word"
61
- require_relative "assemblyai/realtime/types/audio_data"
62
62
  require_relative "assemblyai/realtime/types/force_end_utterance"
63
63
  require_relative "assemblyai/realtime/types/configure_end_utterance_silence_threshold"
64
64
  require_relative "assemblyai/realtime/types/terminate_session"
65
65
  require_relative "assemblyai/realtime/types/audio_encoding"
66
66
  require_relative "assemblyai/realtime/types/realtime_temporary_token_response"
67
- require_relative "assemblyai/realtime/types/receive_message"
68
- require_relative "assemblyai/realtime/types/send_message"
69
67
  require_relative "assemblyai/lemur/types/purge_lemur_request_data_response"
70
68
  require_relative "assemblyai/lemur/types/lemur_base_response"
71
69
  require_relative "assemblyai/lemur/types/lemur_summary_response"
@@ -78,4 +76,7 @@ require_relative "assemblyai/lemur/types/lemur_base_params"
78
76
  require_relative "assemblyai/lemur/types/lemur_question_context"
79
77
  require_relative "assemblyai/lemur/types/lemur_question"
80
78
  require_relative "assemblyai/lemur/types/lemur_model"
79
+ require_relative "assemblyai/streaming/types/streaming"
80
+ require_relative "assemblyai/streaming/types/receive_message"
81
+ require_relative "assemblyai/streaming/types/send_message"
81
82
  require_relative "assemblyai/types/error"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assemblyai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.7
4
+ version: 1.0.0.pre.beta.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-01 00:00:00.000000000 Z
11
+ date: 2024-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http-faraday
@@ -113,7 +113,6 @@ files:
113
113
  - lib/assemblyai/lemur/types/lemur_task_response.rb
114
114
  - lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb
115
115
  - lib/assemblyai/realtime/client.rb
116
- - lib/assemblyai/realtime/types/audio_data.rb
117
116
  - lib/assemblyai/realtime/types/audio_encoding.rb
118
117
  - lib/assemblyai/realtime/types/configure_end_utterance_silence_threshold.rb
119
118
  - lib/assemblyai/realtime/types/final_transcript.rb
@@ -127,12 +126,14 @@ files:
127
126
  - lib/assemblyai/realtime/types/realtime_temporary_token_response.rb
128
127
  - lib/assemblyai/realtime/types/realtime_transcript.rb
129
128
  - lib/assemblyai/realtime/types/realtime_transcript_type.rb
130
- - lib/assemblyai/realtime/types/receive_message.rb
131
- - lib/assemblyai/realtime/types/send_message.rb
132
129
  - lib/assemblyai/realtime/types/session_begins.rb
130
+ - lib/assemblyai/realtime/types/session_information.rb
133
131
  - lib/assemblyai/realtime/types/session_terminated.rb
134
132
  - lib/assemblyai/realtime/types/terminate_session.rb
135
133
  - lib/assemblyai/realtime/types/word.rb
134
+ - lib/assemblyai/streaming/types/receive_message.rb
135
+ - lib/assemblyai/streaming/types/send_message.rb
136
+ - lib/assemblyai/streaming/types/streaming.rb
136
137
  - lib/assemblyai/transcripts/client.rb
137
138
  - lib/assemblyai/transcripts/list_by_url_client.rb
138
139
  - lib/assemblyai/transcripts/polling_client.rb
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module AssemblyAI
4
- class Realtime
5
- AUDIO_DATA = String
6
- end
7
- end
@@ -1,87 +0,0 @@
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_terminated"
8
- require_relative "../../realtime/types/realtime_error"
9
-
10
- module AssemblyAI
11
- class Realtime
12
- # Receive messages from the WebSocket
13
- class ReceiveMessage
14
- # Deserialize a JSON object to an instance of ReceiveMessage
15
- #
16
- # @param json_object [JSON]
17
- # @return [Realtime::ReceiveMessage]
18
- def self.from_json(json_object:)
19
- struct = JSON.parse(json_object, object_class: OpenStruct)
20
- begin
21
- Realtime::SessionBegins.validate_raw(obj: struct)
22
- return Realtime::SessionBegins.from_json(json_object: json_object)
23
- rescue StandardError
24
- # noop
25
- end
26
- begin
27
- Realtime::PartialTranscript.validate_raw(obj: struct)
28
- return Realtime::PartialTranscript.from_json(json_object: json_object)
29
- rescue StandardError
30
- # noop
31
- end
32
- begin
33
- Realtime::FinalTranscript.validate_raw(obj: struct)
34
- return Realtime::FinalTranscript.from_json(json_object: json_object)
35
- rescue StandardError
36
- # noop
37
- end
38
- begin
39
- Realtime::SessionTerminated.validate_raw(obj: struct)
40
- return Realtime::SessionTerminated.from_json(json_object: json_object)
41
- rescue StandardError
42
- # noop
43
- end
44
- begin
45
- Realtime::RealtimeError.validate_raw(obj: struct)
46
- return Realtime::RealtimeError.from_json(json_object: json_object)
47
- rescue StandardError
48
- # noop
49
- end
50
- struct
51
- end
52
-
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.
54
- #
55
- # @param obj [Object]
56
- # @return [Void]
57
- def self.validate_raw(obj:)
58
- begin
59
- return Realtime::SessionBegins.validate_raw(obj: obj)
60
- rescue StandardError
61
- # noop
62
- end
63
- begin
64
- return Realtime::PartialTranscript.validate_raw(obj: obj)
65
- rescue StandardError
66
- # noop
67
- end
68
- begin
69
- return Realtime::FinalTranscript.validate_raw(obj: obj)
70
- rescue StandardError
71
- # noop
72
- end
73
- begin
74
- return Realtime::SessionTerminated.validate_raw(obj: obj)
75
- rescue StandardError
76
- # noop
77
- end
78
- begin
79
- return Realtime::RealtimeError.validate_raw(obj: obj)
80
- rescue StandardError
81
- # noop
82
- end
83
- raise("Passed value matched no type within the union, validation failed.")
84
- end
85
- end
86
- end
87
- end