assemblyai 1.0.0.pre.beta.11 → 1.0.0.pre.beta.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 157742ad6decb8b828c23cf549a4e700d4cb0b2fdd9435bef9ca5e44424fdbda
4
- data.tar.gz: a97d6acfec405cb63d78c6388602ede6ff6c885053feb054f82044ea17658a92
3
+ metadata.gz: 9034fb96ca90c8408fbfd7fc97683c4d9a3ece611dd24c48cf1c4359fdb34f60
4
+ data.tar.gz: dcac6189a3a041f59a0b3eb67f4c27fa9bae181d3823fd514e3dbbd52ff69d71
5
5
  SHA512:
6
- metadata.gz: 3136c68cf8ebeefb44cde0e3e55f968726bbf1d748a414d727ea6e0d73f244ac6a51f4edd688d4343ba857d2db28475fdcd4786f911ab2ce854d9206a3945b8a
7
- data.tar.gz: 8f28783285bea24b5bd283f4385d748d81b0187276f6fedb4923df3be63493191391a99adcc478fd15d9b551186ca054a7822f76d16eae690292420c78d23339
6
+ metadata.gz: 8c949d40ee00af765612f85dd2291050d67b86171d8861927c7f70bc32bcfa06dd7af93e3877ac8d3ed3b2432b9c11c5e9394cc60aa1e34341ec05ad786c8939
7
+ data.tar.gz: 2b2f829a93d8d6c86c8d39c19190f2610edcb154882ba5b0e7b2a49be4ccbf6c6557835a6161ba327ab27bb47fad1b2acbe290c9f221e284f6168eb726d6e039
@@ -75,10 +75,15 @@ module AssemblyAI
75
75
  deprecate_conformer2(speech_model: speech_model)
76
76
  transcript = submit(audio_url: audio_url, speech_model: speech_model, language_code: language_code, punctuate: punctuate, format_text: format_text, dual_channel: dual_channel,
77
77
  webhook_url: webhook_url, webhook_auth_header_name: webhook_auth_header_name, webhook_auth_header_value: webhook_auth_header_value, auto_highlights: auto_highlights, audio_start_from: audio_start_from, audio_end_at: audio_end_at, word_boost: word_boost, boost_param: boost_param, filter_profanity: filter_profanity, redact_pii: redact_pii, redact_pii_audio: redact_pii_audio, redact_pii_audio_quality: redact_pii_audio_quality, redact_pii_policies: redact_pii_policies, redact_pii_sub: redact_pii_sub, speaker_labels: speaker_labels, speakers_expected: speakers_expected, content_safety: content_safety, content_safety_confidence: content_safety_confidence, iab_categories: iab_categories, language_detection: language_detection, custom_spelling: custom_spelling, disfluencies: disfluencies, sentiment_analysis: sentiment_analysis, auto_chapters: auto_chapters, entity_detection: entity_detection, speech_threshold: speech_threshold, summarization: summarization, summary_model: summary_model, summary_type: summary_type, custom_topics: custom_topics, topics: topics, additional_properties: additional_properties, request_options: request_options)
78
- poll_transcript(transcript_id: transcript.id, polling_options: polling_options)
78
+ wait_until_ready(transcript_id: transcript.id, polling_options: polling_options)
79
79
  end
80
80
 
81
- def poll_transcript(transcript_id:, polling_options:)
81
+ # Wait until the transcript is ready. The transcript is ready when the "status" is "completed".
82
+ #
83
+ # @param transcript_id [String] ID of the transcript
84
+ # @param polling_options [PollingOptions]
85
+ # @return [Transcripts::Transcript]
86
+ def wait_until_ready(transcript_id:, polling_options: Transcripts::PollingOptions.new)
82
87
  start_time = Time.now
83
88
  timeout_in_seconds = polling_options.timeout / 1000 if polling_options.timeout.positive?
84
89
  loop do
@@ -97,7 +102,8 @@ module AssemblyAI
97
102
  def deprecate_conformer2(speech_model: nil)
98
103
  warn "[DEPRECATION] `conformer-2` is deprecated. Please use `best` or `nano` instead." if speech_model == "conformer-2"
99
104
  end
100
- private :poll_transcript, :deprecate_conformer2
105
+
106
+ private :deprecate_conformer2
101
107
  end
102
108
 
103
109
  # :nodoc:
@@ -155,18 +161,23 @@ module AssemblyAI
155
161
  Async do
156
162
  transcript = submit(audio_url: audio_url, speech_model: speech_model, language_code: language_code, punctuate: punctuate, format_text: format_text, dual_channel: dual_channel,
157
163
  webhook_url: webhook_url, webhook_auth_header_name: webhook_auth_header_name, webhook_auth_header_value: webhook_auth_header_value, auto_highlights: auto_highlights, audio_start_from: audio_start_from, audio_end_at: audio_end_at, word_boost: word_boost, boost_param: boost_param, filter_profanity: filter_profanity, redact_pii: redact_pii, redact_pii_audio: redact_pii_audio, redact_pii_audio_quality: redact_pii_audio_quality, redact_pii_policies: redact_pii_policies, redact_pii_sub: redact_pii_sub, speaker_labels: speaker_labels, speakers_expected: speakers_expected, content_safety: content_safety, content_safety_confidence: content_safety_confidence, iab_categories: iab_categories, language_detection: language_detection, custom_spelling: custom_spelling, disfluencies: disfluencies, sentiment_analysis: sentiment_analysis, auto_chapters: auto_chapters, entity_detection: entity_detection, speech_threshold: speech_threshold, summarization: summarization, summary_model: summary_model, summary_type: summary_type, custom_topics: custom_topics, topics: topics, additional_properties: additional_properties, request_options: request_options).wait
158
- poll_transcript(transcript_id: transcript.id, polling_options: polling_options).wait
164
+ wait_until_ready(transcript_id: transcript.id, polling_options: polling_options).wait
159
165
  end
160
166
  end
161
167
 
162
- def poll_transcript(transcript_id:, polling_options:)
168
+ # Wait until the transcript is ready. The transcript is ready when the "status" is "completed".
169
+ #
170
+ # @param transcript_id [String] ID of the transcript
171
+ # @param polling_options [PollingOptions]
172
+ # @return [Transcripts::Transcript]
173
+ def wait_until_ready(transcript_id:, polling_options: Transcripts::PollingOptions.new)
163
174
  Async do
164
175
  start_time = Time.now
165
176
  timeout_in_seconds = polling_options.timeout / 1000 if polling_options.timeout.positive?
166
177
  loop do
167
- transcript = get(transcript_id: transcript_id).wait
178
+ transcript = get(transcript_id: transcript_id)
168
179
  if transcript.status == Transcripts::TranscriptStatus::COMPLETED || transcript.status == Transcripts::TranscriptStatus::ERROR
169
- break transcript
180
+ return transcript
170
181
  elsif polling_options.timeout.positive? && Time.now - start_time > timeout_in_seconds
171
182
  raise StandardError, "Polling timeout"
172
183
  end
@@ -180,6 +191,7 @@ module AssemblyAI
180
191
  def deprecate_conformer2(speech_model:)
181
192
  warn "[DEPRECATION] `conformer-2` is deprecated. Please use `best` or `nano` instead." if speech_model == "conformer-2"
182
193
  end
183
- private :poll_transcript, :deprecate_conformer2
194
+
195
+ private :deprecate_conformer2
184
196
  end
185
197
  end
data/lib/assemblyai.rb CHANGED
@@ -14,14 +14,15 @@ module AssemblyAI
14
14
  class Client
15
15
  attr_reader :files, :transcripts, :realtime, :lemur
16
16
 
17
+ # @param api_key [String]
17
18
  # @param environment [Environment]
18
19
  # @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
19
20
  # @param timeout_in_seconds [Long]
20
- # @param api_key [String]
21
+ # @param user_agent [AssemblyAI::UserAgent]
21
22
  # @return [Client]
22
- def initialize(api_key:, environment: Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil)
23
+ def initialize(api_key:, environment: Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil, user_agent: nil)
23
24
  @request_client = RequestClient.new(environment: environment, max_retries: max_retries,
24
- timeout_in_seconds: timeout_in_seconds, api_key: api_key)
25
+ timeout_in_seconds: timeout_in_seconds, api_key: api_key, user_agent: user_agent)
25
26
  @files = FilesClient.new(request_client: @request_client)
26
27
  @transcripts = TranscriptsClient.new(request_client: @request_client)
27
28
  @realtime = RealtimeClient.new(request_client: @request_client)
@@ -32,14 +33,15 @@ module AssemblyAI
32
33
  class AsyncClient
33
34
  attr_reader :files, :transcripts, :realtime, :lemur
34
35
 
36
+ # @param api_key [String]
35
37
  # @param environment [Environment]
36
38
  # @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
37
39
  # @param timeout_in_seconds [Long]
38
- # @param api_key [String]
40
+ # @param user_agent [AssemblyAI::UserAgent]
39
41
  # @return [AsyncClient]
40
- def initialize(api_key:, environment: Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil)
42
+ def initialize(api_key:, environment: Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil, user_agent: nil)
41
43
  @async_request_client = AsyncRequestClient.new(environment: environment, max_retries: max_retries,
42
- timeout_in_seconds: timeout_in_seconds, api_key: api_key)
44
+ timeout_in_seconds: timeout_in_seconds, api_key: api_key, user_agent: user_agent)
43
45
  @files = AsyncFilesClient.new(request_client: @async_request_client)
44
46
  @transcripts = AsyncTranscriptsClient.new(request_client: @async_request_client)
45
47
  @realtime = AsyncRealtimeClient.new(request_client: @async_request_client)
data/lib/gemconfig.rb CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  module AssemblyAI
4
4
  module Gemconfig
5
- VERSION = ""
5
+ VERSION = "1.0.0-beta.12"
6
6
  AUTHORS = [""].freeze
7
- EMAIL = ""
8
- SUMMARY = ""
9
- DESCRIPTION = ""
7
+ EMAIL = "support@assemblyai.com"
8
+ SUMMARY = "AssemblyAI Ruby SDK"
9
+ DESCRIPTION = "The AssemblyAI Ruby SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async, audio intelligence models, as well as the latest LeMUR models.
10
+ The Ruby SDK does not support Streaming STT at this time."
10
11
  HOMEPAGE = "https://github.com/AssemblyAI/assemblyai-ruby-sdk"
11
12
  SOURCE_CODE_URI = "https://github.com/AssemblyAI/assemblyai-ruby-sdk"
12
13
  CHANGELOG_URI = "https://github.com/AssemblyAI/assemblyai-ruby-sdk/blob/master/CHANGELOG.md"
data/lib/requests.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "environment"
4
+ require_relative "user_agent"
4
5
  require "faraday"
5
6
  require "faraday/retry"
6
7
  require "async/http/faraday"
@@ -16,21 +17,23 @@ module AssemblyAI
16
17
  # @return [String]
17
18
  attr_reader :default_environment
18
19
 
20
+ # @param api_key [String]
19
21
  # @param environment [AssemblyAI::Environment]
20
22
  # @param base_url [String]
21
23
  # @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
22
24
  # @param timeout_in_seconds [Long]
23
- # @param api_key [String]
25
+ # @param user_agent [AssemblyAI::UserAgent]
24
26
  # @return [AssemblyAI::RequestClient]
25
27
  def initialize(api_key:, environment: AssemblyAI::Environment::DEFAULT, base_url: nil, max_retries: nil,
26
- timeout_in_seconds: nil)
28
+ timeout_in_seconds: nil, user_agent: nil)
27
29
  @default_environment = environment
28
30
  @base_url = environment || base_url
29
31
  @headers = {
30
32
  "X-Fern-Language": "Ruby",
31
33
  "X-Fern-SDK-Name": "assemblyai",
32
- "X-Fern-SDK-Version": "1.0.0-beta.11",
33
- "Authorization": api_key.to_s
34
+ "X-Fern-SDK-Version": AssemblyAI::Gemconfig::VERSION,
35
+ "Authorization": api_key.to_s,
36
+ "User-Agent": AssemblyAI::UserAgent.merge(AssemblyAI::DefaultUserAgent.instance.user_agent, user_agent).serialize
34
37
  }
35
38
  @conn = Faraday.new(headers: @headers) do |faraday|
36
39
  faraday.request :json
@@ -62,16 +65,18 @@ module AssemblyAI
62
65
  # @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
63
66
  # @param timeout_in_seconds [Long]
64
67
  # @param api_key [String]
68
+ # @param user_agent [AssemblyAI::UserAgent]
65
69
  # @return [AssemblyAI::AsyncRequestClient]
66
70
  def initialize(api_key:, environment: AssemblyAI::Environment::DEFAULT, base_url: nil, max_retries: nil,
67
- timeout_in_seconds: nil)
71
+ timeout_in_seconds: nil, user_agent: nil)
68
72
  @default_environment = environment
69
73
  @base_url = environment || base_url
70
74
  @headers = {
71
75
  "X-Fern-Language": "Ruby",
72
76
  "X-Fern-SDK-Name": "assemblyai",
73
- "X-Fern-SDK-Version": "1.0.0-beta.11",
74
- "Authorization": api_key.to_s
77
+ "X-Fern-SDK-Version": AssemblyAI::Gemconfig::VERSION,
78
+ "Authorization": api_key.to_s,
79
+ "User-Agent": AssemblyAI::UserAgent.merge(AssemblyAI::DefaultUserAgent.instance.user_agent, user_agent).serialize
75
80
  }
76
81
  @conn = Faraday.new(headers: @headers) do |faraday|
77
82
  faraday.request :json
data/lib/user_agent.rb ADDED
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "singleton"
4
+
5
+ module AssemblyAI
6
+ class UserAgentItem
7
+ attr_reader :name, :value, :version
8
+
9
+ def initialize(name:, version:)
10
+ @name = name
11
+ @version = version
12
+ end
13
+ end
14
+
15
+ class UserAgent
16
+ attr_reader :user_agent_items
17
+
18
+ def initialize
19
+ @user_agent_items = {}
20
+ end
21
+
22
+ # @param key [String]
23
+ # @param user_agent_item [AssemblyAI::UserAgentItem]
24
+ def add_item(key, user_agent_item)
25
+ if user_agent_item.nil?
26
+ @user_agent_items.delete(key)
27
+ else
28
+ @user_agent_items[key] = user_agent_item
29
+ end
30
+ end
31
+
32
+ # @param user_agent1 [AssemblyAI::UserAgent]
33
+ # @param user_agent2 [AssemblyAI::UserAgent]
34
+ # @return [AssemblyAI::UserAgent]
35
+ def self.merge(user_agent1, user_agent2)
36
+ merged_user_agent = UserAgent.new
37
+
38
+ user_agent1&.user_agent_items&.each do |key, item|
39
+ merged_user_agent.add_item(key, item)
40
+ end
41
+
42
+ user_agent2&.user_agent_items&.each do |key, item|
43
+ merged_user_agent.add_item(key, item)
44
+ end
45
+
46
+ merged_user_agent
47
+ end
48
+
49
+ # @return [String]
50
+ def serialize
51
+ serialized_items = @user_agent_items.map do |key, item|
52
+ "#{key}=#{item.name}/#{item.version}"
53
+ end.join(" ")
54
+
55
+ "AssemblyAI/1.0 (#{serialized_items})"
56
+ end
57
+ end
58
+
59
+ class DefaultUserAgent
60
+ include Singleton
61
+
62
+ attr_reader :user_agent
63
+
64
+ def initialize
65
+ @user_agent = UserAgent.new
66
+ @user_agent.add_item("sdk", UserAgentItem.new(name: "Ruby", version: AssemblyAI::Gemconfig::VERSION))
67
+ end
68
+ end
69
+ end
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.11
4
+ version: 1.0.0.pre.beta.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-14 00:00:00.000000000 Z
11
+ date: 2024-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http-faraday
@@ -90,8 +90,10 @@ dependencies:
90
90
  - - "<"
91
91
  - !ruby/object:Gem::Version
92
92
  version: '3.0'
93
- description: ''
94
- email: ''
93
+ description: |-
94
+ The AssemblyAI Ruby SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async, audio intelligence models, as well as the latest LeMUR models.
95
+ The Ruby SDK does not support Streaming STT at this time.
96
+ email: support@assemblyai.com
95
97
  executables: []
96
98
  extensions: []
97
99
  extra_rdoc_files: []
@@ -190,6 +192,7 @@ files:
190
192
  - lib/gemconfig.rb
191
193
  - lib/requests.rb
192
194
  - lib/types_export.rb
195
+ - lib/user_agent.rb
193
196
  homepage: https://github.com/AssemblyAI/assemblyai-ruby-sdk
194
197
  licenses: []
195
198
  metadata:
@@ -214,5 +217,5 @@ requirements: []
214
217
  rubygems_version: 3.1.6
215
218
  signing_key:
216
219
  specification_version: 4
217
- summary: ''
220
+ summary: AssemblyAI Ruby SDK
218
221
  test_files: []