assemblyai 1.0.0.pre.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/assemblyai/files/client.rb +63 -0
- data/lib/assemblyai/files/types/uploaded_file.rb +47 -0
- data/lib/assemblyai/lemur/client.rb +390 -0
- data/lib/assemblyai/lemur/types/lemur_action_items_response.rb +52 -0
- data/lib/assemblyai/lemur/types/lemur_base_params.rb +99 -0
- data/lib/assemblyai/lemur/types/lemur_base_params_context.rb +75 -0
- data/lib/assemblyai/lemur/types/lemur_base_response.rb +47 -0
- data/lib/assemblyai/lemur/types/lemur_model.rb +13 -0
- data/lib/assemblyai/lemur/types/lemur_question.rb +74 -0
- data/lib/assemblyai/lemur/types/lemur_question_answer.rb +53 -0
- data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +56 -0
- data/lib/assemblyai/lemur/types/lemur_question_context.rb +75 -0
- data/lib/assemblyai/lemur/types/lemur_summary_response.rb +52 -0
- data/lib/assemblyai/lemur/types/lemur_task_response.rb +52 -0
- data/lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb +58 -0
- data/lib/assemblyai/realtime/client.rb +61 -0
- data/lib/assemblyai/realtime/types/audio_data.rb +7 -0
- data/lib/assemblyai/realtime/types/audio_encoding.rb +8 -0
- data/lib/assemblyai/realtime/types/final_transcript.rb +107 -0
- data/lib/assemblyai/realtime/types/message_type.rb +13 -0
- data/lib/assemblyai/realtime/types/partial_transcript.rb +94 -0
- data/lib/assemblyai/realtime/types/realtime_base_message.rb +48 -0
- data/lib/assemblyai/realtime/types/realtime_base_transcript.rb +87 -0
- data/lib/assemblyai/realtime/types/realtime_error.rb +47 -0
- data/lib/assemblyai/realtime/types/realtime_message.rb +115 -0
- data/lib/assemblyai/realtime/types/realtime_temporary_token_response.rb +47 -0
- data/lib/assemblyai/realtime/types/realtime_transcript.rb +76 -0
- data/lib/assemblyai/realtime/types/realtime_transcript_type.rb +8 -0
- data/lib/assemblyai/realtime/types/session_begins.rb +58 -0
- data/lib/assemblyai/realtime/types/session_terminated.rb +47 -0
- data/lib/assemblyai/realtime/types/terminate_session.rb +56 -0
- data/lib/assemblyai/realtime/types/word.rb +62 -0
- data/lib/assemblyai/transcripts/client.rb +525 -0
- data/lib/assemblyai/transcripts/polling_client.rb +173 -0
- data/lib/assemblyai/transcripts/types/audio_intelligence_model_status.rb +8 -0
- data/lib/assemblyai/transcripts/types/auto_highlight_result.rb +66 -0
- data/lib/assemblyai/transcripts/types/auto_highlights_result.rb +53 -0
- data/lib/assemblyai/transcripts/types/chapter.rb +68 -0
- data/lib/assemblyai/transcripts/types/content_safety_label.rb +57 -0
- data/lib/assemblyai/transcripts/types/content_safety_label_result.rb +84 -0
- data/lib/assemblyai/transcripts/types/content_safety_labels_result.rb +75 -0
- data/lib/assemblyai/transcripts/types/entity.rb +69 -0
- data/lib/assemblyai/transcripts/types/entity_type.rb +38 -0
- data/lib/assemblyai/transcripts/types/page_details.rb +74 -0
- data/lib/assemblyai/transcripts/types/paragraphs_response.rb +67 -0
- data/lib/assemblyai/transcripts/types/pii_policy.rb +36 -0
- data/lib/assemblyai/transcripts/types/polling_options.rb +21 -0
- data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +8 -0
- data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +53 -0
- data/lib/assemblyai/transcripts/types/redacted_audio_status.rb +7 -0
- data/lib/assemblyai/transcripts/types/sentences_response.rb +67 -0
- data/lib/assemblyai/transcripts/types/sentiment.rb +8 -0
- data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +82 -0
- data/lib/assemblyai/transcripts/types/severity_score_summary.rb +57 -0
- data/lib/assemblyai/transcripts/types/speech_model.rb +7 -0
- data/lib/assemblyai/transcripts/types/substitution_policy.rb +8 -0
- data/lib/assemblyai/transcripts/types/subtitle_format.rb +8 -0
- data/lib/assemblyai/transcripts/types/summary_model.rb +8 -0
- data/lib/assemblyai/transcripts/types/summary_type.rb +14 -0
- data/lib/assemblyai/transcripts/types/timestamp.rb +53 -0
- data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +68 -0
- data/lib/assemblyai/transcripts/types/topic_detection_result.rb +68 -0
- data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +52 -0
- data/lib/assemblyai/transcripts/types/transcript.rb +454 -0
- data/lib/assemblyai/transcripts/types/transcript_boost_param.rb +8 -0
- data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +53 -0
- data/lib/assemblyai/transcripts/types/transcript_language_code.rb +29 -0
- data/lib/assemblyai/transcripts/types/transcript_list.rb +62 -0
- data/lib/assemblyai/transcripts/types/transcript_list_item.rb +82 -0
- data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +280 -0
- data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +84 -0
- data/lib/assemblyai/transcripts/types/transcript_sentence.rb +84 -0
- data/lib/assemblyai/transcripts/types/transcript_status.rb +8 -0
- data/lib/assemblyai/transcripts/types/transcript_utterance.rb +84 -0
- data/lib/assemblyai/transcripts/types/transcript_word.rb +68 -0
- data/lib/assemblyai/transcripts/types/word_search_match.rb +63 -0
- data/lib/assemblyai/transcripts/types/word_search_response.rb +61 -0
- data/lib/assemblyai/transcripts/types/word_search_timestamp.rb +7 -0
- data/lib/assemblyai/types/error.rb +50 -0
- data/lib/assemblyai.rb +48 -0
- data/lib/environment.rb +7 -0
- data/lib/gemconfig.rb +14 -0
- data/lib/requests.rb +87 -0
- data/lib/types_export.rb +75 -0
- metadata +170 -0
@@ -0,0 +1,525 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../requests"
|
4
|
+
require_relative "types/transcript_status"
|
5
|
+
require_relative "types/transcript_list"
|
6
|
+
require_relative "types/speech_model"
|
7
|
+
require_relative "types/transcript_language_code"
|
8
|
+
require_relative "types/transcript_boost_param"
|
9
|
+
require_relative "types/redact_pii_audio_quality"
|
10
|
+
require_relative "types/pii_policy"
|
11
|
+
require_relative "types/substitution_policy"
|
12
|
+
require_relative "types/transcript_custom_spelling"
|
13
|
+
require_relative "types/summary_model"
|
14
|
+
require_relative "types/summary_type"
|
15
|
+
require_relative "types/transcript"
|
16
|
+
require_relative "types/subtitle_format"
|
17
|
+
require_relative "types/sentences_response"
|
18
|
+
require_relative "types/paragraphs_response"
|
19
|
+
require_relative "types/word_search_response"
|
20
|
+
require_relative "types/redacted_audio_response"
|
21
|
+
require "async"
|
22
|
+
|
23
|
+
module AssemblyAI
|
24
|
+
class TranscriptsClient
|
25
|
+
attr_reader :request_client
|
26
|
+
|
27
|
+
# @param request_client [RequestClient]
|
28
|
+
# @return [TranscriptsClient]
|
29
|
+
def initialize(request_client:)
|
30
|
+
# @type [RequestClient]
|
31
|
+
@request_client = request_client
|
32
|
+
end
|
33
|
+
|
34
|
+
# Retrieve a list of transcripts you created
|
35
|
+
#
|
36
|
+
# @param limit [Integer] Maximum amount of transcripts to retrieve
|
37
|
+
# @param status [TRANSCRIPT_STATUS] Filter by transcript status
|
38
|
+
# @param created_on [String] Only get transcripts created on this date
|
39
|
+
# @param before_id [String] Get transcripts that were created before this transcript ID
|
40
|
+
# @param after_id [String] Get transcripts that were created after this transcript ID
|
41
|
+
# @param throttled_only [Boolean] Only get throttled transcripts, overrides the status filter
|
42
|
+
# @param request_options [RequestOptions]
|
43
|
+
# @return [Transcripts::TranscriptList]
|
44
|
+
def list(limit: nil, status: nil, created_on: nil, before_id: nil, after_id: nil, throttled_only: nil,
|
45
|
+
request_options: nil)
|
46
|
+
response = @request_client.conn.get("/v2/transcript") do |req|
|
47
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
48
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
49
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
50
|
+
req.params = {
|
51
|
+
**(request_options&.additional_query_parameters || {}),
|
52
|
+
"limit": limit,
|
53
|
+
"status": status,
|
54
|
+
"created_on": created_on,
|
55
|
+
"before_id": before_id,
|
56
|
+
"after_id": after_id,
|
57
|
+
"throttled_only": throttled_only
|
58
|
+
}.compact
|
59
|
+
end
|
60
|
+
Transcripts::TranscriptList.from_json(json_object: response.body)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Create a transcript from an audio or video file that is accessible via a URL.
|
64
|
+
#
|
65
|
+
# @param speech_model [Transcripts::SPEECH_MODEL]
|
66
|
+
# @param language_code [TRANSCRIPT_LANGUAGE_CODE]
|
67
|
+
# @param punctuate [Boolean] Enable Automatic Punctuation, can be true or false
|
68
|
+
# @param format_text [Boolean] Enable Text Formatting, can be true or false
|
69
|
+
# @param dual_channel [Boolean] Enable [Dual Channel](https://www.assemblyai.com/docs/models/speech-recognition#dual-channel-transcription) transcription, can be true or false.
|
70
|
+
# @param webhook_url [String] The URL to which AssemblyAI send webhooks upon trancription completion
|
71
|
+
# @param webhook_auth_header_name [String] The header name which should be sent back with webhook calls
|
72
|
+
# @param webhook_auth_header_value [String] Specify a header name and value to send back with a webhook call for added security
|
73
|
+
# @param auto_highlights [Boolean] Whether Key Phrases is enabled, either true or false
|
74
|
+
# @param audio_start_from [Integer] The point in time, in milliseconds, to begin transcribing in your media file
|
75
|
+
# @param audio_end_at [Integer] The point in time, in milliseconds, to stop transcribing in your media file
|
76
|
+
# @param word_boost [Array<String>] The list of custom vocabulary to boost transcription probability for
|
77
|
+
# @param boost_param [TRANSCRIPT_BOOST_PARAM] The word boost parameter value
|
78
|
+
# @param filter_profanity [Boolean] Filter profanity from the transcribed text, can be true or false
|
79
|
+
# @param redact_pii [Boolean] Redact PII from the transcribed text using the Redact PII model, can be true or false
|
80
|
+
# @param redact_pii_audio [Boolean] Generate a copy of the original media file with spoken PII "beeped" out, can be true or false. See [PII redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more details.
|
81
|
+
# @param redact_pii_audio_quality [REDACT_PII_AUDIO_QUALITY] Controls the filetype of the audio created by redact_pii_audio. Currently supports mp3 (default) and wav. See [PII redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more details.
|
82
|
+
# @param redact_pii_policies [Array<Transcripts::PII_POLICY>] The list of PII Redaction policies to enable. See [PII redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more details.
|
83
|
+
# @param redact_pii_sub [SUBSTITUTION_POLICY]
|
84
|
+
# @param speaker_labels [Boolean] Enable [Speaker diarization](https://www.assemblyai.com/docs/models/speaker-diarization), can be true or false
|
85
|
+
# @param speakers_expected [Integer] Tells the speaker label model how many speakers it should attempt to identify, up to 10. See [Speaker diarization](https://www.assemblyai.com/docs/models/speaker-diarization) for more details.
|
86
|
+
# @param content_safety [Boolean] Enable [Content Moderation](https://www.assemblyai.com/docs/models/content-moderation), can be true or false
|
87
|
+
# @param content_safety_confidence [Integer] The confidence threshold for content moderation. Values must be between 25 and 100.
|
88
|
+
# @param iab_categories [Boolean] Enable [Topic Detection](https://www.assemblyai.com/docs/models/topic-detection), can be true or false
|
89
|
+
# @param language_detection [Boolean] Whether [Automatic language detection](https://www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection) was enabled in the transcription request, either true or false.
|
90
|
+
# @param custom_spelling [Array<Hash>] Customize how words are spelled and formatted using to and from valuesRequest of type Array<Transcripts::TranscriptCustomSpelling>, as a Hash
|
91
|
+
# * :from (Array<String>)
|
92
|
+
# * :to (String)
|
93
|
+
# @param disfluencies [Boolean] Transcribe Filler Words, like "umm", in your media file; can be true or false
|
94
|
+
# @param sentiment_analysis [Boolean] Enable [Sentiment Analysis](https://www.assemblyai.com/docs/models/sentiment-analysis), can be true or false
|
95
|
+
# @param auto_chapters [Boolean] Enable [Auto Chapters](https://www.assemblyai.com/docs/models/auto-chapters), can be true or false
|
96
|
+
# @param entity_detection [Boolean] Enable [Entity Detection](https://www.assemblyai.com/docs/models/entity-detection), can be true or false
|
97
|
+
# @param speech_threshold [Float] Reject audio files that contain less than this fraction of speech.
|
98
|
+
# Valid values are in the range [0, 1] inclusive.
|
99
|
+
# @param summarization [Boolean] Enable [Summarization](https://www.assemblyai.com/docs/models/summarization), can be true or false
|
100
|
+
# @param summary_model [SUMMARY_MODEL] The model to summarize the transcript
|
101
|
+
# @param summary_type [SUMMARY_TYPE] The type of summary
|
102
|
+
# @param custom_topics [Boolean] Whether custom topics is enabled, either true or false
|
103
|
+
# @param topics [Array<String>] The list of custom topics provided, if custom topics is enabled
|
104
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
105
|
+
# @param audio_url [String] The URL of the audio or video file to transcribe.
|
106
|
+
# @param request_options [RequestOptions]
|
107
|
+
# @return [Transcripts::Transcript]
|
108
|
+
def submit(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil,
|
109
|
+
webhook_url: nil, webhook_auth_header_name: nil, webhook_auth_header_value: nil, auto_highlights: nil, audio_start_from: nil, audio_end_at: nil, word_boost: nil, boost_param: nil, filter_profanity: nil, redact_pii: nil, redact_pii_audio: nil, redact_pii_audio_quality: nil, redact_pii_policies: nil, redact_pii_sub: nil, speaker_labels: nil, speakers_expected: nil, content_safety: nil, content_safety_confidence: nil, iab_categories: nil, language_detection: nil, custom_spelling: nil, disfluencies: nil, sentiment_analysis: nil, auto_chapters: nil, entity_detection: nil, speech_threshold: nil, summarization: nil, summary_model: nil, summary_type: nil, custom_topics: nil, topics: nil, additional_properties: nil, request_options: nil)
|
110
|
+
response = @request_client.conn.post("/v2/transcript") do |req|
|
111
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
112
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
113
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
114
|
+
req.body = {
|
115
|
+
**(request_options&.additional_body_parameters || {}),
|
116
|
+
speech_model: speech_model,
|
117
|
+
language_code: language_code,
|
118
|
+
punctuate: punctuate,
|
119
|
+
format_text: format_text,
|
120
|
+
dual_channel: dual_channel,
|
121
|
+
webhook_url: webhook_url,
|
122
|
+
webhook_auth_header_name: webhook_auth_header_name,
|
123
|
+
webhook_auth_header_value: webhook_auth_header_value,
|
124
|
+
auto_highlights: auto_highlights,
|
125
|
+
audio_start_from: audio_start_from,
|
126
|
+
audio_end_at: audio_end_at,
|
127
|
+
word_boost: word_boost,
|
128
|
+
boost_param: boost_param,
|
129
|
+
filter_profanity: filter_profanity,
|
130
|
+
redact_pii: redact_pii,
|
131
|
+
redact_pii_audio: redact_pii_audio,
|
132
|
+
redact_pii_audio_quality: redact_pii_audio_quality,
|
133
|
+
redact_pii_policies: redact_pii_policies,
|
134
|
+
redact_pii_sub: redact_pii_sub,
|
135
|
+
speaker_labels: speaker_labels,
|
136
|
+
speakers_expected: speakers_expected,
|
137
|
+
content_safety: content_safety,
|
138
|
+
content_safety_confidence: content_safety_confidence,
|
139
|
+
iab_categories: iab_categories,
|
140
|
+
language_detection: language_detection,
|
141
|
+
custom_spelling: custom_spelling,
|
142
|
+
disfluencies: disfluencies,
|
143
|
+
sentiment_analysis: sentiment_analysis,
|
144
|
+
auto_chapters: auto_chapters,
|
145
|
+
entity_detection: entity_detection,
|
146
|
+
speech_threshold: speech_threshold,
|
147
|
+
summarization: summarization,
|
148
|
+
summary_model: summary_model,
|
149
|
+
summary_type: summary_type,
|
150
|
+
custom_topics: custom_topics,
|
151
|
+
topics: topics,
|
152
|
+
additional_properties: additional_properties,
|
153
|
+
audio_url: audio_url
|
154
|
+
}.compact
|
155
|
+
end
|
156
|
+
Transcripts::Transcript.from_json(json_object: response.body)
|
157
|
+
end
|
158
|
+
|
159
|
+
# Get the transcript resource. The transcript is ready when the "status" is "completed".
|
160
|
+
#
|
161
|
+
# @param transcript_id [String] ID of the transcript
|
162
|
+
# @param request_options [RequestOptions]
|
163
|
+
# @return [Transcripts::Transcript]
|
164
|
+
def get(transcript_id:, request_options: nil)
|
165
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}") do |req|
|
166
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
167
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
168
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
169
|
+
end
|
170
|
+
Transcripts::Transcript.from_json(json_object: response.body)
|
171
|
+
end
|
172
|
+
|
173
|
+
# Delete the transcript
|
174
|
+
#
|
175
|
+
# @param transcript_id [String] ID of the transcript
|
176
|
+
# @param request_options [RequestOptions]
|
177
|
+
# @return [Transcripts::Transcript]
|
178
|
+
def delete(transcript_id:, request_options: nil)
|
179
|
+
response = @request_client.conn.delete("/v2/transcript/#{transcript_id}") do |req|
|
180
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
181
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
182
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
183
|
+
end
|
184
|
+
Transcripts::Transcript.from_json(json_object: response.body)
|
185
|
+
end
|
186
|
+
|
187
|
+
# Export your transcript in SRT or VTT format, to be plugged into a video player for subtitles and closed captions.
|
188
|
+
#
|
189
|
+
# @param transcript_id [String] ID of the transcript
|
190
|
+
# @param subtitle_format [SUBTITLE_FORMAT] The format of the captions
|
191
|
+
# @param chars_per_caption [Integer] The maximum number of characters per caption
|
192
|
+
# @param request_options [RequestOptions]
|
193
|
+
# @return [String]
|
194
|
+
def get_subtitles(transcript_id:, subtitle_format:, chars_per_caption: nil, request_options: nil)
|
195
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}/#{subtitle_format}") do |req|
|
196
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
197
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
198
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
199
|
+
req.params = {
|
200
|
+
**(request_options&.additional_query_parameters || {}),
|
201
|
+
"chars_per_caption": chars_per_caption
|
202
|
+
}.compact
|
203
|
+
end
|
204
|
+
response.body
|
205
|
+
end
|
206
|
+
|
207
|
+
# Get the transcript split by sentences. The API will attempt to semantically segment the transcript into sentences to create more reader-friendly transcripts.
|
208
|
+
#
|
209
|
+
# @param transcript_id [String] ID of the transcript
|
210
|
+
# @param request_options [RequestOptions]
|
211
|
+
# @return [Transcripts::SentencesResponse]
|
212
|
+
def get_sentences(transcript_id:, request_options: nil)
|
213
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}/sentences") do |req|
|
214
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
215
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
216
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
217
|
+
end
|
218
|
+
Transcripts::SentencesResponse.from_json(json_object: response.body)
|
219
|
+
end
|
220
|
+
|
221
|
+
# Get the transcript split by paragraphs. The API will attempt to semantically segment your transcript into paragraphs to create more reader-friendly transcripts.
|
222
|
+
#
|
223
|
+
# @param transcript_id [String] ID of the transcript
|
224
|
+
# @param request_options [RequestOptions]
|
225
|
+
# @return [Transcripts::ParagraphsResponse]
|
226
|
+
def get_paragraphs(transcript_id:, request_options: nil)
|
227
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}/paragraphs") do |req|
|
228
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
229
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
230
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
231
|
+
end
|
232
|
+
Transcripts::ParagraphsResponse.from_json(json_object: response.body)
|
233
|
+
end
|
234
|
+
|
235
|
+
# Search through the transcript for a specific set of keywords. You can search for individual words, numbers, or phrases containing up to five words or numbers.
|
236
|
+
#
|
237
|
+
# @param transcript_id [String] ID of the transcript
|
238
|
+
# @param words [String] Keywords to search for
|
239
|
+
# @param request_options [RequestOptions]
|
240
|
+
# @return [Transcripts::WordSearchResponse]
|
241
|
+
def word_search(transcript_id:, words: nil, request_options: nil)
|
242
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}/word-search") do |req|
|
243
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
244
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
245
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
246
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "words": words }.compact
|
247
|
+
end
|
248
|
+
Transcripts::WordSearchResponse.from_json(json_object: response.body)
|
249
|
+
end
|
250
|
+
|
251
|
+
# Retrieve the redacted audio object containing the status and URL to the redacted audio.
|
252
|
+
#
|
253
|
+
# @param transcript_id [String] ID of the transcript
|
254
|
+
# @param request_options [RequestOptions]
|
255
|
+
# @return [Transcripts::RedactedAudioResponse]
|
256
|
+
def get_redacted_audio(transcript_id:, request_options: nil)
|
257
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}/redacted-audio") do |req|
|
258
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
259
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
260
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
261
|
+
end
|
262
|
+
Transcripts::RedactedAudioResponse.from_json(json_object: response.body)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
class AsyncTranscriptsClient
|
267
|
+
attr_reader :request_client
|
268
|
+
|
269
|
+
# @param request_client [AsyncRequestClient]
|
270
|
+
# @return [AsyncTranscriptsClient]
|
271
|
+
def initialize(request_client:)
|
272
|
+
# @type [AsyncRequestClient]
|
273
|
+
@request_client = request_client
|
274
|
+
end
|
275
|
+
|
276
|
+
# Retrieve a list of transcripts you created
|
277
|
+
#
|
278
|
+
# @param limit [Integer] Maximum amount of transcripts to retrieve
|
279
|
+
# @param status [TRANSCRIPT_STATUS] Filter by transcript status
|
280
|
+
# @param created_on [String] Only get transcripts created on this date
|
281
|
+
# @param before_id [String] Get transcripts that were created before this transcript ID
|
282
|
+
# @param after_id [String] Get transcripts that were created after this transcript ID
|
283
|
+
# @param throttled_only [Boolean] Only get throttled transcripts, overrides the status filter
|
284
|
+
# @param request_options [RequestOptions]
|
285
|
+
# @return [Transcripts::TranscriptList]
|
286
|
+
def list(limit: nil, status: nil, created_on: nil, before_id: nil, after_id: nil, throttled_only: nil,
|
287
|
+
request_options: nil)
|
288
|
+
Async do
|
289
|
+
response = @request_client.conn.get("/v2/transcript") do |req|
|
290
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
291
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
292
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
293
|
+
req.params = {
|
294
|
+
**(request_options&.additional_query_parameters || {}),
|
295
|
+
"limit": limit,
|
296
|
+
"status": status,
|
297
|
+
"created_on": created_on,
|
298
|
+
"before_id": before_id,
|
299
|
+
"after_id": after_id,
|
300
|
+
"throttled_only": throttled_only
|
301
|
+
}.compact
|
302
|
+
end
|
303
|
+
Transcripts::TranscriptList.from_json(json_object: response.body)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
# Create a transcript from an audio or video file that is accessible via a URL.
|
308
|
+
#
|
309
|
+
# @param speech_model [Transcripts::SPEECH_MODEL]
|
310
|
+
# @param language_code [TRANSCRIPT_LANGUAGE_CODE]
|
311
|
+
# @param punctuate [Boolean] Enable Automatic Punctuation, can be true or false
|
312
|
+
# @param format_text [Boolean] Enable Text Formatting, can be true or false
|
313
|
+
# @param dual_channel [Boolean] Enable [Dual Channel](https://www.assemblyai.com/docs/models/speech-recognition#dual-channel-transcription) transcription, can be true or false.
|
314
|
+
# @param webhook_url [String] The URL to which AssemblyAI send webhooks upon trancription completion
|
315
|
+
# @param webhook_auth_header_name [String] The header name which should be sent back with webhook calls
|
316
|
+
# @param webhook_auth_header_value [String] Specify a header name and value to send back with a webhook call for added security
|
317
|
+
# @param auto_highlights [Boolean] Whether Key Phrases is enabled, either true or false
|
318
|
+
# @param audio_start_from [Integer] The point in time, in milliseconds, to begin transcribing in your media file
|
319
|
+
# @param audio_end_at [Integer] The point in time, in milliseconds, to stop transcribing in your media file
|
320
|
+
# @param word_boost [Array<String>] The list of custom vocabulary to boost transcription probability for
|
321
|
+
# @param boost_param [TRANSCRIPT_BOOST_PARAM] The word boost parameter value
|
322
|
+
# @param filter_profanity [Boolean] Filter profanity from the transcribed text, can be true or false
|
323
|
+
# @param redact_pii [Boolean] Redact PII from the transcribed text using the Redact PII model, can be true or false
|
324
|
+
# @param redact_pii_audio [Boolean] Generate a copy of the original media file with spoken PII "beeped" out, can be true or false. See [PII redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more details.
|
325
|
+
# @param redact_pii_audio_quality [REDACT_PII_AUDIO_QUALITY] Controls the filetype of the audio created by redact_pii_audio. Currently supports mp3 (default) and wav. See [PII redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more details.
|
326
|
+
# @param redact_pii_policies [Array<Transcripts::PII_POLICY>] The list of PII Redaction policies to enable. See [PII redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more details.
|
327
|
+
# @param redact_pii_sub [SUBSTITUTION_POLICY]
|
328
|
+
# @param speaker_labels [Boolean] Enable [Speaker diarization](https://www.assemblyai.com/docs/models/speaker-diarization), can be true or false
|
329
|
+
# @param speakers_expected [Integer] Tells the speaker label model how many speakers it should attempt to identify, up to 10. See [Speaker diarization](https://www.assemblyai.com/docs/models/speaker-diarization) for more details.
|
330
|
+
# @param content_safety [Boolean] Enable [Content Moderation](https://www.assemblyai.com/docs/models/content-moderation), can be true or false
|
331
|
+
# @param content_safety_confidence [Integer] The confidence threshold for content moderation. Values must be between 25 and 100.
|
332
|
+
# @param iab_categories [Boolean] Enable [Topic Detection](https://www.assemblyai.com/docs/models/topic-detection), can be true or false
|
333
|
+
# @param language_detection [Boolean] Whether [Automatic language detection](https://www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection) was enabled in the transcription request, either true or false.
|
334
|
+
# @param custom_spelling [Array<Hash>] Customize how words are spelled and formatted using to and from valuesRequest of type Array<Transcripts::TranscriptCustomSpelling>, as a Hash
|
335
|
+
# * :from (Array<String>)
|
336
|
+
# * :to (String)
|
337
|
+
# @param disfluencies [Boolean] Transcribe Filler Words, like "umm", in your media file; can be true or false
|
338
|
+
# @param sentiment_analysis [Boolean] Enable [Sentiment Analysis](https://www.assemblyai.com/docs/models/sentiment-analysis), can be true or false
|
339
|
+
# @param auto_chapters [Boolean] Enable [Auto Chapters](https://www.assemblyai.com/docs/models/auto-chapters), can be true or false
|
340
|
+
# @param entity_detection [Boolean] Enable [Entity Detection](https://www.assemblyai.com/docs/models/entity-detection), can be true or false
|
341
|
+
# @param speech_threshold [Float] Reject audio files that contain less than this fraction of speech.
|
342
|
+
# Valid values are in the range [0, 1] inclusive.
|
343
|
+
# @param summarization [Boolean] Enable [Summarization](https://www.assemblyai.com/docs/models/summarization), can be true or false
|
344
|
+
# @param summary_model [SUMMARY_MODEL] The model to summarize the transcript
|
345
|
+
# @param summary_type [SUMMARY_TYPE] The type of summary
|
346
|
+
# @param custom_topics [Boolean] Whether custom topics is enabled, either true or false
|
347
|
+
# @param topics [Array<String>] The list of custom topics provided, if custom topics is enabled
|
348
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
349
|
+
# @param audio_url [String] The URL of the audio or video file to transcribe.
|
350
|
+
# @param request_options [RequestOptions]
|
351
|
+
# @return [Transcripts::Transcript]
|
352
|
+
def submit(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil,
|
353
|
+
webhook_url: nil, webhook_auth_header_name: nil, webhook_auth_header_value: nil, auto_highlights: nil, audio_start_from: nil, audio_end_at: nil, word_boost: nil, boost_param: nil, filter_profanity: nil, redact_pii: nil, redact_pii_audio: nil, redact_pii_audio_quality: nil, redact_pii_policies: nil, redact_pii_sub: nil, speaker_labels: nil, speakers_expected: nil, content_safety: nil, content_safety_confidence: nil, iab_categories: nil, language_detection: nil, custom_spelling: nil, disfluencies: nil, sentiment_analysis: nil, auto_chapters: nil, entity_detection: nil, speech_threshold: nil, summarization: nil, summary_model: nil, summary_type: nil, custom_topics: nil, topics: nil, additional_properties: nil, request_options: nil)
|
354
|
+
Async do
|
355
|
+
response = @request_client.conn.post("/v2/transcript") do |req|
|
356
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
357
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
358
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
359
|
+
req.body = {
|
360
|
+
**(request_options&.additional_body_parameters || {}),
|
361
|
+
speech_model: speech_model,
|
362
|
+
language_code: language_code,
|
363
|
+
punctuate: punctuate,
|
364
|
+
format_text: format_text,
|
365
|
+
dual_channel: dual_channel,
|
366
|
+
webhook_url: webhook_url,
|
367
|
+
webhook_auth_header_name: webhook_auth_header_name,
|
368
|
+
webhook_auth_header_value: webhook_auth_header_value,
|
369
|
+
auto_highlights: auto_highlights,
|
370
|
+
audio_start_from: audio_start_from,
|
371
|
+
audio_end_at: audio_end_at,
|
372
|
+
word_boost: word_boost,
|
373
|
+
boost_param: boost_param,
|
374
|
+
filter_profanity: filter_profanity,
|
375
|
+
redact_pii: redact_pii,
|
376
|
+
redact_pii_audio: redact_pii_audio,
|
377
|
+
redact_pii_audio_quality: redact_pii_audio_quality,
|
378
|
+
redact_pii_policies: redact_pii_policies,
|
379
|
+
redact_pii_sub: redact_pii_sub,
|
380
|
+
speaker_labels: speaker_labels,
|
381
|
+
speakers_expected: speakers_expected,
|
382
|
+
content_safety: content_safety,
|
383
|
+
content_safety_confidence: content_safety_confidence,
|
384
|
+
iab_categories: iab_categories,
|
385
|
+
language_detection: language_detection,
|
386
|
+
custom_spelling: custom_spelling,
|
387
|
+
disfluencies: disfluencies,
|
388
|
+
sentiment_analysis: sentiment_analysis,
|
389
|
+
auto_chapters: auto_chapters,
|
390
|
+
entity_detection: entity_detection,
|
391
|
+
speech_threshold: speech_threshold,
|
392
|
+
summarization: summarization,
|
393
|
+
summary_model: summary_model,
|
394
|
+
summary_type: summary_type,
|
395
|
+
custom_topics: custom_topics,
|
396
|
+
topics: topics,
|
397
|
+
additional_properties: additional_properties,
|
398
|
+
audio_url: audio_url
|
399
|
+
}.compact
|
400
|
+
end
|
401
|
+
Transcripts::Transcript.from_json(json_object: response.body)
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
# Get the transcript resource. The transcript is ready when the "status" is "completed".
|
406
|
+
#
|
407
|
+
# @param transcript_id [String] ID of the transcript
|
408
|
+
# @param request_options [RequestOptions]
|
409
|
+
# @return [Transcripts::Transcript]
|
410
|
+
def get(transcript_id:, request_options: nil)
|
411
|
+
Async do
|
412
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}") do |req|
|
413
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
414
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
415
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
416
|
+
end
|
417
|
+
Transcripts::Transcript.from_json(json_object: response.body)
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
# Delete the transcript
|
422
|
+
#
|
423
|
+
# @param transcript_id [String] ID of the transcript
|
424
|
+
# @param request_options [RequestOptions]
|
425
|
+
# @return [Transcripts::Transcript]
|
426
|
+
def delete(transcript_id:, request_options: nil)
|
427
|
+
Async do
|
428
|
+
response = @request_client.conn.delete("/v2/transcript/#{transcript_id}") do |req|
|
429
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
430
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
431
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
432
|
+
end
|
433
|
+
Transcripts::Transcript.from_json(json_object: response.body)
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
# Export your transcript in SRT or VTT format, to be plugged into a video player for subtitles and closed captions.
|
438
|
+
#
|
439
|
+
# @param transcript_id [String] ID of the transcript
|
440
|
+
# @param subtitle_format [SUBTITLE_FORMAT] The format of the captions
|
441
|
+
# @param chars_per_caption [Integer] The maximum number of characters per caption
|
442
|
+
# @param request_options [RequestOptions]
|
443
|
+
# @return [String]
|
444
|
+
def get_subtitles(transcript_id:, subtitle_format:, chars_per_caption: nil, request_options: nil)
|
445
|
+
Async do
|
446
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}/#{subtitle_format}") do |req|
|
447
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
448
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
449
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
450
|
+
req.params = {
|
451
|
+
**(request_options&.additional_query_parameters || {}),
|
452
|
+
"chars_per_caption": chars_per_caption
|
453
|
+
}.compact
|
454
|
+
end
|
455
|
+
response.body
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
# Get the transcript split by sentences. The API will attempt to semantically segment the transcript into sentences to create more reader-friendly transcripts.
|
460
|
+
#
|
461
|
+
# @param transcript_id [String] ID of the transcript
|
462
|
+
# @param request_options [RequestOptions]
|
463
|
+
# @return [Transcripts::SentencesResponse]
|
464
|
+
def get_sentences(transcript_id:, request_options: nil)
|
465
|
+
Async do
|
466
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}/sentences") do |req|
|
467
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
468
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
469
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
470
|
+
end
|
471
|
+
Transcripts::SentencesResponse.from_json(json_object: response.body)
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
# Get the transcript split by paragraphs. The API will attempt to semantically segment your transcript into paragraphs to create more reader-friendly transcripts.
|
476
|
+
#
|
477
|
+
# @param transcript_id [String] ID of the transcript
|
478
|
+
# @param request_options [RequestOptions]
|
479
|
+
# @return [Transcripts::ParagraphsResponse]
|
480
|
+
def get_paragraphs(transcript_id:, request_options: nil)
|
481
|
+
Async do
|
482
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}/paragraphs") do |req|
|
483
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
484
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
485
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
486
|
+
end
|
487
|
+
Transcripts::ParagraphsResponse.from_json(json_object: response.body)
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
491
|
+
# Search through the transcript for a specific set of keywords. You can search for individual words, numbers, or phrases containing up to five words or numbers.
|
492
|
+
#
|
493
|
+
# @param transcript_id [String] ID of the transcript
|
494
|
+
# @param words [String] Keywords to search for
|
495
|
+
# @param request_options [RequestOptions]
|
496
|
+
# @return [Transcripts::WordSearchResponse]
|
497
|
+
def word_search(transcript_id:, words: nil, request_options: nil)
|
498
|
+
Async do
|
499
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}/word-search") do |req|
|
500
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
501
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
502
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
503
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "words": words }.compact
|
504
|
+
end
|
505
|
+
Transcripts::WordSearchResponse.from_json(json_object: response.body)
|
506
|
+
end
|
507
|
+
end
|
508
|
+
|
509
|
+
# Retrieve the redacted audio object containing the status and URL to the redacted audio.
|
510
|
+
#
|
511
|
+
# @param transcript_id [String] ID of the transcript
|
512
|
+
# @param request_options [RequestOptions]
|
513
|
+
# @return [Transcripts::RedactedAudioResponse]
|
514
|
+
def get_redacted_audio(transcript_id:, request_options: nil)
|
515
|
+
Async do
|
516
|
+
response = @request_client.conn.get("/v2/transcript/#{transcript_id}/redacted-audio") do |req|
|
517
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
518
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
519
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
520
|
+
end
|
521
|
+
Transcripts::RedactedAudioResponse.from_json(json_object: response.body)
|
522
|
+
end
|
523
|
+
end
|
524
|
+
end
|
525
|
+
end
|