omniai-google 2.7.8 → 2.7.9
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 +4 -4
- data/lib/omniai/google/transcribe_helpers.rb +13 -2
- data/lib/omniai/google/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b718eb7991b71acbb1339523addc4b6336af98a93a978336cf79e696a838fbe
|
4
|
+
data.tar.gz: 61a97b3e556841f7880fc0f2ca3eb832940a02098e7a55dcf41eb976766ab791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65504958cd3c74f5302c6362a72d86d9506637889a4005de4a92ac462567ea7925cfe774e12399bae64eba012cbbf1fa70fcac2e30010d869d1b3ed099b5d6dc
|
7
|
+
data.tar.gz: 680380f9201edf0a4bc4d6ebfe3a1e08c4b8c30c34b8a99d4d70dbed4beac6eb0a453bd2b2a75efc774628ff79359b7cc616e7fe91a9d1f07c3afe3a6778cae5
|
@@ -190,13 +190,13 @@ module OmniAI
|
|
190
190
|
# Add authentication if using credentials
|
191
191
|
connection = connection.auth("Bearer #{@client.send(:auth).split.last}") if @client.credentials?
|
192
192
|
|
193
|
-
max_attempts =
|
193
|
+
max_attempts = calculate_max_polling_attempts
|
194
194
|
attempt = 0
|
195
195
|
|
196
196
|
loop do
|
197
197
|
attempt += 1
|
198
198
|
|
199
|
-
raise
|
199
|
+
raise StandardError, "Operation timed out after #{max_attempts * 15} seconds" if attempt > max_attempts
|
200
200
|
|
201
201
|
operation_response = connection.get("/v2/#{operation_name}", params: operation_params)
|
202
202
|
|
@@ -454,6 +454,17 @@ module OmniAI
|
|
454
454
|
credentials = @client.instance_variable_get(:@credentials)
|
455
455
|
::Google::Cloud::Storage.new(project_id:, credentials:)
|
456
456
|
end
|
457
|
+
|
458
|
+
# @return [Integer]
|
459
|
+
def calculate_max_polling_attempts
|
460
|
+
file_size_bytes = calculate_file_size
|
461
|
+
assumed_bitrate_bps = 48_000
|
462
|
+
estimated_duration_seconds = (file_size_bytes * 8.0) / assumed_bitrate_bps
|
463
|
+
estimated_processing_seconds = estimated_duration_seconds * 0.3
|
464
|
+
total_wait_seconds = estimated_processing_seconds + 90
|
465
|
+
final_wait_seconds = total_wait_seconds.clamp(180, 10_800)
|
466
|
+
(final_wait_seconds / 15).ceil
|
467
|
+
end
|
457
468
|
end
|
458
469
|
end
|
459
470
|
end
|