assemblyai 1.0.0.pre.beta.5 → 1.0.0.pre.beta.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assemblyai/files/client.rb +52 -6
- data/lib/assemblyai/realtime/client.rb +2 -2
- data/lib/assemblyai/realtime/types/realtime_temporary_token_response.rb +2 -2
- data/lib/assemblyai/realtime/types/receive_message.rb +5 -5
- data/lib/assemblyai/realtime/types/send_message.rb +3 -3
- data/lib/assemblyai/realtime/types/terminate_session.rb +2 -2
- data/lib/assemblyai/transcripts/client.rb +4 -2
- data/lib/assemblyai/transcripts/types/page_details.rb +7 -6
- data/lib/assemblyai/transcripts/types/speech_model.rb +1 -0
- data/lib/assemblyai/transcripts/types/substitution_policy.rb +2 -2
- data/lib/assemblyai/transcripts/types/transcript_list.rb +1 -0
- data/lib/assemblyai/transcripts/types/transcript_list_item.rb +11 -4
- data/lib/requests.rb +2 -2
- data/lib/types_export.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76ddcd8ef7bd03dab334e872387e6ea6f01d1c93d26ec1a1ffc57a29ec498f1a
|
4
|
+
data.tar.gz: 57abade0a92ef0dd0031f27098d9f7bdebfc17f7445776409af4b8627afe11a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17410d40ef0225953ff55910ad561334b7ef6a7cda2e9b190103885878c920b573abcffc9fddc904aefccf896e03629640e7884efde32e4df39e549e17847252
|
7
|
+
data.tar.gz: 1c4739c4fee6647ac9edffd00a1a84c7bd7b6fa0064e5126097e6194372a967a976acfecee128a5c7a08738f9864044278247574c91ddb5b40b0903197f49cbd
|
@@ -17,16 +17,39 @@ module AssemblyAI
|
|
17
17
|
|
18
18
|
# Upload your media file directly to the AssemblyAI API if it isn't accessible via a URL already.
|
19
19
|
#
|
20
|
-
# @param
|
20
|
+
# @param file [String, IO] File path, Base64 String, or an IO object (e.g. Faraday::UploadIO, etc.)
|
21
21
|
# @param request_options [RequestOptions]
|
22
22
|
# @return [Files::UploadedFile]
|
23
|
-
def upload(
|
23
|
+
def upload(file:, request_options: nil)
|
24
24
|
response = @request_client.conn.post("/v2/upload") do |req|
|
25
|
+
if file.is_a? String
|
26
|
+
begin
|
27
|
+
path = Pathname.new(file)
|
28
|
+
rescue StandardError
|
29
|
+
file_data = file
|
30
|
+
end
|
31
|
+
unless path.nil?
|
32
|
+
if path.file?
|
33
|
+
file_data = File.new(file)
|
34
|
+
elsif path.directory?
|
35
|
+
raise "file path has to be a path to file, but is a path to directory"
|
36
|
+
else
|
37
|
+
raise "file at path does not exist"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
else
|
41
|
+
file_data = file
|
42
|
+
end
|
25
43
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
26
44
|
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
27
45
|
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
28
46
|
req.headers["Content-Type"] = "application/octet-stream"
|
29
|
-
|
47
|
+
if file.is_a? File
|
48
|
+
req.headers["Content-Length"] = File.size(file_data.path).to_s
|
49
|
+
else
|
50
|
+
req.headers["Transfer-Encoding"] = "chunked"
|
51
|
+
end
|
52
|
+
req.body = file_data
|
30
53
|
end
|
31
54
|
Files::UploadedFile.from_json(json_object: response.body)
|
32
55
|
end
|
@@ -44,17 +67,40 @@ module AssemblyAI
|
|
44
67
|
|
45
68
|
# Upload your media file directly to the AssemblyAI API if it isn't accessible via a URL already.
|
46
69
|
#
|
47
|
-
# @param
|
70
|
+
# @param file [String, IO] File path, Base64 String, or an IO object (e.g. Faraday::UploadIO, etc.)
|
48
71
|
# @param request_options [RequestOptions]
|
49
72
|
# @return [Files::UploadedFile]
|
50
|
-
def upload(
|
73
|
+
def upload(file:, request_options: nil)
|
51
74
|
Async do
|
52
75
|
response = @request_client.conn.post("/v2/upload") do |req|
|
76
|
+
if file.is_a? String
|
77
|
+
begin
|
78
|
+
path = Pathname.new(file)
|
79
|
+
rescue StandardError
|
80
|
+
file_data = file
|
81
|
+
end
|
82
|
+
unless path.nil?
|
83
|
+
if path.file?
|
84
|
+
file_data = File.new(file)
|
85
|
+
elsif path.directory?
|
86
|
+
raise "file path has to be a path to file, but is a path to directory"
|
87
|
+
else
|
88
|
+
raise "file at path does not exist"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
else
|
92
|
+
file_data = file
|
93
|
+
end
|
53
94
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
54
95
|
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
55
96
|
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
56
97
|
req.headers["Content-Type"] = "application/octet-stream"
|
57
|
-
|
98
|
+
if file.is_a? File
|
99
|
+
req.headers["Content-Length"] = File.size(file_data.path).to_s
|
100
|
+
else
|
101
|
+
req.headers["Transfer-Encoding"] = "chunked"
|
102
|
+
end
|
103
|
+
req.body = file_data
|
58
104
|
end
|
59
105
|
Files::UploadedFile.from_json(json_object: response.body)
|
60
106
|
end
|
@@ -15,7 +15,7 @@ module AssemblyAI
|
|
15
15
|
@request_client = request_client
|
16
16
|
end
|
17
17
|
|
18
|
-
# Create a temporary authentication token for
|
18
|
+
# Create a temporary authentication token for Streaming Speech-to-Text
|
19
19
|
#
|
20
20
|
# @param expires_in [Integer] The amount of time until the token expires in seconds
|
21
21
|
# @param request_options [RequestOptions]
|
@@ -41,7 +41,7 @@ module AssemblyAI
|
|
41
41
|
@request_client = request_client
|
42
42
|
end
|
43
43
|
|
44
|
-
# Create a temporary authentication token for
|
44
|
+
# Create a temporary authentication token for Streaming Speech-to-Text
|
45
45
|
#
|
46
46
|
# @param expires_in [Integer] The amount of time until the token expires in seconds
|
47
47
|
# @param request_options [RequestOptions]
|
@@ -7,11 +7,11 @@ module AssemblyAI
|
|
7
7
|
class RealtimeTemporaryTokenResponse
|
8
8
|
attr_reader :token, :additional_properties
|
9
9
|
|
10
|
-
# @param token [String] The temporary authentication token for
|
10
|
+
# @param token [String] The temporary authentication token for Streaming Speech-to-Text
|
11
11
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
12
12
|
# @return [Realtime::RealtimeTemporaryTokenResponse]
|
13
13
|
def initialize(token:, additional_properties: nil)
|
14
|
-
# @type [String] The temporary authentication token for
|
14
|
+
# @type [String] The temporary authentication token for Streaming Speech-to-Text
|
15
15
|
@token = token
|
16
16
|
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
17
17
|
@additional_properties = additional_properties
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "json"
|
4
|
-
require_relative "session_begins"
|
5
|
-
require_relative "partial_transcript"
|
6
|
-
require_relative "final_transcript"
|
7
|
-
require_relative "session_terminated"
|
8
|
-
require_relative "realtime_error"
|
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
9
|
|
10
10
|
module AssemblyAI
|
11
11
|
class Realtime
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "json"
|
4
|
-
require_relative "terminate_session"
|
5
|
-
require_relative "force_end_utterance"
|
6
|
-
require_relative "configure_end_utterance_silence_threshold"
|
4
|
+
require_relative "../../realtime/types/terminate_session"
|
5
|
+
require_relative "../../realtime/types/force_end_utterance"
|
6
|
+
require_relative "../../realtime/types/configure_end_utterance_silence_threshold"
|
7
7
|
|
8
8
|
module AssemblyAI
|
9
9
|
class Realtime
|
@@ -7,11 +7,11 @@ module AssemblyAI
|
|
7
7
|
class TerminateSession
|
8
8
|
attr_reader :terminate_session, :additional_properties
|
9
9
|
|
10
|
-
# @param terminate_session [Boolean] Set to true to end your
|
10
|
+
# @param terminate_session [Boolean] Set to true to end your streaming session forever
|
11
11
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
12
12
|
# @return [Realtime::TerminateSession]
|
13
13
|
def initialize(terminate_session:, additional_properties: nil)
|
14
|
-
# @type [Boolean] Set to true to end your
|
14
|
+
# @type [Boolean] Set to true to end your streaming session forever
|
15
15
|
@terminate_session = terminate_session
|
16
16
|
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
17
17
|
@additional_properties = additional_properties
|
@@ -31,7 +31,8 @@ module AssemblyAI
|
|
31
31
|
@request_client = request_client
|
32
32
|
end
|
33
33
|
|
34
|
-
# Retrieve a list of transcripts you created
|
34
|
+
# Retrieve a list of transcripts you created.
|
35
|
+
# Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
|
35
36
|
#
|
36
37
|
# @param limit [Integer] Maximum amount of transcripts to retrieve
|
37
38
|
# @param status [Transcripts::TranscriptStatus] Filter by transcript status
|
@@ -273,7 +274,8 @@ module AssemblyAI
|
|
273
274
|
@request_client = request_client
|
274
275
|
end
|
275
276
|
|
276
|
-
# Retrieve a list of transcripts you created
|
277
|
+
# Retrieve a list of transcripts you created.
|
278
|
+
# Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
|
277
279
|
#
|
278
280
|
# @param limit [Integer] Maximum amount of transcripts to retrieve
|
279
281
|
# @param status [Transcripts::TranscriptStatus] Filter by transcript status
|
@@ -4,26 +4,27 @@ require "json"
|
|
4
4
|
|
5
5
|
module AssemblyAI
|
6
6
|
class Transcripts
|
7
|
+
# Details of the transcript page. Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
|
7
8
|
class PageDetails
|
8
9
|
attr_reader :limit, :result_count, :current_url, :prev_url, :next_url, :additional_properties
|
9
10
|
|
10
11
|
# @param limit [Integer]
|
11
12
|
# @param result_count [Integer]
|
12
13
|
# @param current_url [String]
|
13
|
-
# @param prev_url [String]
|
14
|
-
# @param next_url [String]
|
14
|
+
# @param prev_url [String] The URL to the next page of transcripts. The previous URL always points to a page with older transcripts.
|
15
|
+
# @param next_url [String] The URL to the next page of transcripts. The next URL always points to a page with newer transcripts.
|
15
16
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
16
17
|
# @return [Transcripts::PageDetails]
|
17
|
-
def initialize(limit:, result_count:, current_url:, prev_url
|
18
|
+
def initialize(limit:, result_count:, current_url:, prev_url: nil, next_url: nil, additional_properties: nil)
|
18
19
|
# @type [Integer]
|
19
20
|
@limit = limit
|
20
21
|
# @type [Integer]
|
21
22
|
@result_count = result_count
|
22
23
|
# @type [String]
|
23
24
|
@current_url = current_url
|
24
|
-
# @type [String]
|
25
|
+
# @type [String] The URL to the next page of transcripts. The previous URL always points to a page with older transcripts.
|
25
26
|
@prev_url = prev_url
|
26
|
-
# @type [String]
|
27
|
+
# @type [String] The URL to the next page of transcripts. The next URL always points to a page with newer transcripts.
|
27
28
|
@next_url = next_url
|
28
29
|
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
29
30
|
@additional_properties = additional_properties
|
@@ -66,7 +67,7 @@ module AssemblyAI
|
|
66
67
|
obj.limit.is_a?(Integer) != false || raise("Passed value for field obj.limit is not the expected type, validation failed.")
|
67
68
|
obj.result_count.is_a?(Integer) != false || raise("Passed value for field obj.result_count is not the expected type, validation failed.")
|
68
69
|
obj.current_url.is_a?(String) != false || raise("Passed value for field obj.current_url is not the expected type, validation failed.")
|
69
|
-
obj.prev_url
|
70
|
+
obj.prev_url&.is_a?(String) != false || raise("Passed value for field obj.prev_url is not the expected type, validation failed.")
|
70
71
|
obj.next_url&.is_a?(String) != false || raise("Passed value for field obj.next_url is not the expected type, validation failed.")
|
71
72
|
end
|
72
73
|
end
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module AssemblyAI
|
4
4
|
class Transcripts
|
5
|
-
# The replacement logic for detected PII, can be "
|
5
|
+
# The replacement logic for detected PII, can be "entity_name" or "hash". See [PII redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more details.
|
6
6
|
class SubstitutionPolicy
|
7
|
-
|
7
|
+
ENTITY_NAME = "entity_name"
|
8
8
|
HASH = "hash"
|
9
9
|
end
|
10
10
|
end
|
@@ -6,6 +6,7 @@ require "json"
|
|
6
6
|
|
7
7
|
module AssemblyAI
|
8
8
|
class Transcripts
|
9
|
+
# A list of transcripts. Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
|
9
10
|
class TranscriptList
|
10
11
|
attr_reader :page_details, :transcripts, :additional_properties
|
11
12
|
|
@@ -7,7 +7,7 @@ require "json"
|
|
7
7
|
module AssemblyAI
|
8
8
|
class Transcripts
|
9
9
|
class TranscriptListItem
|
10
|
-
attr_reader :id, :resource_url, :status, :created, :completed, :audio_url, :additional_properties
|
10
|
+
attr_reader :id, :resource_url, :status, :created, :completed, :audio_url, :error, :additional_properties
|
11
11
|
|
12
12
|
# @param id [String]
|
13
13
|
# @param resource_url [String]
|
@@ -15,9 +15,11 @@ module AssemblyAI
|
|
15
15
|
# @param created [DateTime]
|
16
16
|
# @param completed [DateTime]
|
17
17
|
# @param audio_url [String]
|
18
|
+
# @param error [String] Error message of why the transcript failed
|
18
19
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
19
20
|
# @return [Transcripts::TranscriptListItem]
|
20
|
-
def initialize(id:, resource_url:, status:, created:, completed:, audio_url:,
|
21
|
+
def initialize(id:, resource_url:, status:, created:, completed:, audio_url:, error: nil,
|
22
|
+
additional_properties: nil)
|
21
23
|
# @type [String]
|
22
24
|
@id = id
|
23
25
|
# @type [String]
|
@@ -30,6 +32,8 @@ module AssemblyAI
|
|
30
32
|
@completed = completed
|
31
33
|
# @type [String]
|
32
34
|
@audio_url = audio_url
|
35
|
+
# @type [String] Error message of why the transcript failed
|
36
|
+
@error = error
|
33
37
|
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
34
38
|
@additional_properties = additional_properties
|
35
39
|
end
|
@@ -47,8 +51,9 @@ module AssemblyAI
|
|
47
51
|
created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
|
48
52
|
completed = (DateTime.parse(parsed_json["completed"]) unless parsed_json["completed"].nil?)
|
49
53
|
audio_url = struct.audio_url
|
54
|
+
error = struct.error
|
50
55
|
new(id: id, resource_url: resource_url, status: status, created: created, completed: completed,
|
51
|
-
audio_url: audio_url, additional_properties: struct)
|
56
|
+
audio_url: audio_url, error: error, additional_properties: struct)
|
52
57
|
end
|
53
58
|
|
54
59
|
# Serialize an instance of TranscriptListItem to a JSON object
|
@@ -61,7 +66,8 @@ module AssemblyAI
|
|
61
66
|
"status": @status,
|
62
67
|
"created": @created,
|
63
68
|
"completed": @completed,
|
64
|
-
"audio_url": @audio_url
|
69
|
+
"audio_url": @audio_url,
|
70
|
+
"error": @error
|
65
71
|
}.to_json
|
66
72
|
end
|
67
73
|
|
@@ -76,6 +82,7 @@ module AssemblyAI
|
|
76
82
|
obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
77
83
|
obj.completed.is_a?(DateTime) != false || raise("Passed value for field obj.completed is not the expected type, validation failed.")
|
78
84
|
obj.audio_url.is_a?(String) != false || raise("Passed value for field obj.audio_url is not the expected type, validation failed.")
|
85
|
+
obj.error&.is_a?(String) != false || raise("Passed value for field obj.error is not the expected type, validation failed.")
|
79
86
|
end
|
80
87
|
end
|
81
88
|
end
|
data/lib/requests.rb
CHANGED
@@ -20,7 +20,7 @@ module AssemblyAI
|
|
20
20
|
@headers = {
|
21
21
|
"X-Fern-Language": "Ruby",
|
22
22
|
"X-Fern-SDK-Name": "assemblyai",
|
23
|
-
"X-Fern-SDK-Version": "1.0.0-beta.
|
23
|
+
"X-Fern-SDK-Version": "1.0.0-beta.7",
|
24
24
|
"Authorization": api_key.to_s
|
25
25
|
}
|
26
26
|
@conn = Faraday.new(@base_url, headers: @headers) do |faraday|
|
@@ -46,7 +46,7 @@ module AssemblyAI
|
|
46
46
|
@headers = {
|
47
47
|
"X-Fern-Language": "Ruby",
|
48
48
|
"X-Fern-SDK-Name": "assemblyai",
|
49
|
-
"X-Fern-SDK-Version": "1.0.0-beta.
|
49
|
+
"X-Fern-SDK-Version": "1.0.0-beta.7",
|
50
50
|
"Authorization": api_key.to_s
|
51
51
|
}
|
52
52
|
@conn = Faraday.new(@base_url, headers: @headers) do |faraday|
|
data/lib/types_export.rb
CHANGED
@@ -46,26 +46,26 @@ require_relative "assemblyai/transcripts/types/page_details"
|
|
46
46
|
require_relative "assemblyai/transcripts/types/transcript_list_item"
|
47
47
|
require_relative "assemblyai/transcripts/types/transcript_list"
|
48
48
|
require_relative "assemblyai/transcripts/types/audio_intelligence_model_status"
|
49
|
+
require_relative "assemblyai/realtime/types/realtime_base_message"
|
49
50
|
require_relative "assemblyai/realtime/types/session_begins"
|
50
51
|
require_relative "assemblyai/realtime/types/partial_transcript"
|
51
52
|
require_relative "assemblyai/realtime/types/final_transcript"
|
52
53
|
require_relative "assemblyai/realtime/types/session_terminated"
|
53
54
|
require_relative "assemblyai/realtime/types/realtime_error"
|
54
|
-
require_relative "assemblyai/realtime/types/receive_message"
|
55
|
-
require_relative "assemblyai/realtime/types/audio_data"
|
56
|
-
require_relative "assemblyai/realtime/types/terminate_session"
|
57
|
-
require_relative "assemblyai/realtime/types/force_end_utterance"
|
58
|
-
require_relative "assemblyai/realtime/types/configure_end_utterance_silence_threshold"
|
59
|
-
require_relative "assemblyai/realtime/types/send_message"
|
60
|
-
require_relative "assemblyai/realtime/types/realtime_temporary_token_response"
|
61
|
-
require_relative "assemblyai/realtime/types/realtime_base_message"
|
62
55
|
require_relative "assemblyai/realtime/types/realtime_message"
|
63
56
|
require_relative "assemblyai/realtime/types/message_type"
|
64
57
|
require_relative "assemblyai/realtime/types/realtime_transcript_type"
|
65
58
|
require_relative "assemblyai/realtime/types/realtime_transcript"
|
66
59
|
require_relative "assemblyai/realtime/types/realtime_base_transcript"
|
67
60
|
require_relative "assemblyai/realtime/types/word"
|
61
|
+
require_relative "assemblyai/realtime/types/audio_data"
|
62
|
+
require_relative "assemblyai/realtime/types/force_end_utterance"
|
63
|
+
require_relative "assemblyai/realtime/types/configure_end_utterance_silence_threshold"
|
64
|
+
require_relative "assemblyai/realtime/types/terminate_session"
|
68
65
|
require_relative "assemblyai/realtime/types/audio_encoding"
|
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
69
|
require_relative "assemblyai/lemur/types/purge_lemur_request_data_response"
|
70
70
|
require_relative "assemblyai/lemur/types/lemur_base_response"
|
71
71
|
require_relative "assemblyai/lemur/types/lemur_summary_response"
|
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.
|
4
|
+
version: 1.0.0.pre.beta.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-http-faraday
|