assemblyai 1.0.0.pre.beta.6 → 1.0.0.pre.beta.8

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 +256 -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 -54
  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 -31
  10. data/lib/assemblyai/lemur/types/lemur_question_answer.rb +28 -14
  11. data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +29 -14
  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 +32 -16
  17. data/lib/assemblyai/realtime/types/configure_end_utterance_silence_threshold.rb +24 -13
  18. data/lib/assemblyai/realtime/types/final_transcript.rb +72 -41
  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 +62 -34
  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 +21 -12
  27. data/lib/assemblyai/realtime/types/realtime_transcript.rb +15 -9
  28. data/lib/assemblyai/realtime/types/session_begins.rb +31 -14
  29. data/lib/assemblyai/realtime/types/session_information.rb +69 -0
  30. data/lib/assemblyai/realtime/types/session_terminated.rb +20 -11
  31. data/lib/assemblyai/realtime/types/terminate_session.rb +21 -12
  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/streaming/types/send_message.rb +86 -0
  35. data/lib/assemblyai/streaming/types/streaming.rb +11 -0
  36. data/lib/assemblyai/transcripts/client.rb +54 -20
  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/page_details.rb +60 -33
  47. data/lib/assemblyai/transcripts/types/paragraphs_response.rb +37 -19
  48. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +4 -1
  49. data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +29 -15
  50. data/lib/assemblyai/transcripts/types/sentences_response.rb +37 -19
  51. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +62 -35
  52. data/lib/assemblyai/transcripts/types/severity_score_summary.rb +32 -16
  53. data/lib/assemblyai/transcripts/types/speech_model.rb +2 -0
  54. data/lib/assemblyai/transcripts/types/substitution_policy.rb +4 -2
  55. data/lib/assemblyai/transcripts/types/timestamp.rb +28 -14
  56. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +39 -19
  57. data/lib/assemblyai/transcripts/types/topic_detection_result.rb +40 -21
  58. data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +31 -15
  59. data/lib/assemblyai/transcripts/types/transcript.rb +512 -293
  60. data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +30 -15
  61. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +3 -2
  62. data/lib/assemblyai/transcripts/types/transcript_list.rb +33 -16
  63. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +63 -30
  64. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +334 -191
  65. data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +61 -33
  66. data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +30 -16
  67. data/lib/assemblyai/transcripts/types/transcript_sentence.rb +61 -33
  68. data/lib/assemblyai/transcripts/types/transcript_status.rb +2 -1
  69. data/lib/assemblyai/transcripts/types/transcript_utterance.rb +55 -31
  70. data/lib/assemblyai/transcripts/types/transcript_word.rb +55 -24
  71. data/lib/assemblyai/transcripts/types/word_search_match.rb +40 -20
  72. data/lib/assemblyai/transcripts/types/word_search_response.rb +36 -17
  73. data/lib/assemblyai/types/error.rb +32 -16
  74. data/lib/requests.rb +80 -34
  75. data/lib/types_export.rb +9 -8
  76. metadata +6 -5
  77. data/lib/assemblyai/realtime/types/audio_data.rb +0 -7
  78. data/lib/assemblyai/realtime/types/receive_message.rb +0 -87
  79. data/lib/assemblyai/realtime/types/send_message.rb +0 -74
@@ -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
@@ -43,7 +44,7 @@ module AssemblyAI
43
44
  # @return [Transcripts::TranscriptList]
44
45
  def list(limit: nil, status: nil, created_on: nil, before_id: nil, after_id: nil, throttled_only: nil,
45
46
  request_options: nil)
46
- response = @request_client.conn.get("/v2/transcript") do |req|
47
+ response = @request_client.conn.get do |req|
47
48
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
48
49
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
49
50
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -56,6 +57,7 @@ module AssemblyAI
56
57
  "after_id": after_id,
57
58
  "throttled_only": throttled_only
58
59
  }.compact
60
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
59
61
  end
60
62
  Transcripts::TranscriptList.from_json(json_object: response.body)
61
63
  end
@@ -107,7 +109,8 @@ module AssemblyAI
107
109
  # @return [Transcripts::Transcript]
108
110
  def submit(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil,
109
111
  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|
112
+ deprecate_conformer2(speech_model: speech_model)
113
+ response = @request_client.conn.post do |req|
111
114
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
112
115
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
113
116
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -152,6 +155,7 @@ module AssemblyAI
152
155
  additional_properties: additional_properties,
153
156
  audio_url: audio_url
154
157
  }.compact
158
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
155
159
  end
156
160
  Transcripts::Transcript.from_json(json_object: response.body)
157
161
  end
@@ -162,10 +166,11 @@ module AssemblyAI
162
166
  # @param request_options [RequestOptions]
163
167
  # @return [Transcripts::Transcript]
164
168
  def get(transcript_id:, request_options: nil)
165
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}") do |req|
169
+ response = @request_client.conn.get do |req|
166
170
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
167
171
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
168
172
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
173
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}"
169
174
  end
170
175
  Transcripts::Transcript.from_json(json_object: response.body)
171
176
  end
@@ -176,10 +181,11 @@ module AssemblyAI
176
181
  # @param request_options [RequestOptions]
177
182
  # @return [Transcripts::Transcript]
178
183
  def delete(transcript_id:, request_options: nil)
179
- response = @request_client.conn.delete("/v2/transcript/#{transcript_id}") do |req|
184
+ response = @request_client.conn.delete do |req|
180
185
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
181
186
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
182
187
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
188
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}"
183
189
  end
184
190
  Transcripts::Transcript.from_json(json_object: response.body)
185
191
  end
@@ -192,7 +198,7 @@ module AssemblyAI
192
198
  # @param request_options [RequestOptions]
193
199
  # @return [String]
194
200
  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|
201
+ response = @request_client.conn.get do |req|
196
202
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
197
203
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
198
204
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -200,6 +206,7 @@ module AssemblyAI
200
206
  **(request_options&.additional_query_parameters || {}),
201
207
  "chars_per_caption": chars_per_caption
202
208
  }.compact
209
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/#{subtitle_format}"
203
210
  end
204
211
  response.body
205
212
  end
@@ -210,10 +217,11 @@ module AssemblyAI
210
217
  # @param request_options [RequestOptions]
211
218
  # @return [Transcripts::SentencesResponse]
212
219
  def get_sentences(transcript_id:, request_options: nil)
213
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/sentences") do |req|
220
+ response = @request_client.conn.get do |req|
214
221
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
215
222
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
216
223
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
224
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/sentences"
217
225
  end
218
226
  Transcripts::SentencesResponse.from_json(json_object: response.body)
219
227
  end
@@ -224,10 +232,11 @@ module AssemblyAI
224
232
  # @param request_options [RequestOptions]
225
233
  # @return [Transcripts::ParagraphsResponse]
226
234
  def get_paragraphs(transcript_id:, request_options: nil)
227
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/paragraphs") do |req|
235
+ response = @request_client.conn.get do |req|
228
236
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
229
237
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
230
238
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
239
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/paragraphs"
231
240
  end
232
241
  Transcripts::ParagraphsResponse.from_json(json_object: response.body)
233
242
  end
@@ -239,11 +248,12 @@ module AssemblyAI
239
248
  # @param request_options [RequestOptions]
240
249
  # @return [Transcripts::WordSearchResponse]
241
250
  def word_search(transcript_id:, words: nil, request_options: nil)
242
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/word-search") do |req|
251
+ response = @request_client.conn.get do |req|
243
252
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
244
253
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
245
254
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
246
255
  req.params = { **(request_options&.additional_query_parameters || {}), "words": words }.compact
256
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/word-search"
247
257
  end
248
258
  Transcripts::WordSearchResponse.from_json(json_object: response.body)
249
259
  end
@@ -254,13 +264,20 @@ module AssemblyAI
254
264
  # @param request_options [RequestOptions]
255
265
  # @return [Transcripts::RedactedAudioResponse]
256
266
  def get_redacted_audio(transcript_id:, request_options: nil)
257
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/redacted-audio") do |req|
267
+ response = @request_client.conn.get do |req|
258
268
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
259
269
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
260
270
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
271
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/redacted-audio"
261
272
  end
262
273
  Transcripts::RedactedAudioResponse.from_json(json_object: response.body)
263
274
  end
275
+
276
+ # @param speech_model [Transcripts::SpeechModel]
277
+ def deprecate_conformer2(speech_model: nil)
278
+ warn "[DEPRECATION] `conformer-2` is deprecated. Please use `best` or `nano` instead." if speech_model == "conformer-2"
279
+ end
280
+ private :deprecate_conformer2
264
281
  end
265
282
 
266
283
  class AsyncTranscriptsClient
@@ -273,7 +290,8 @@ module AssemblyAI
273
290
  @request_client = request_client
274
291
  end
275
292
 
276
- # Retrieve a list of transcripts you created
293
+ # Retrieve a list of transcripts you created.
294
+ # Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
277
295
  #
278
296
  # @param limit [Integer] Maximum amount of transcripts to retrieve
279
297
  # @param status [Transcripts::TranscriptStatus] Filter by transcript status
@@ -286,7 +304,7 @@ module AssemblyAI
286
304
  def list(limit: nil, status: nil, created_on: nil, before_id: nil, after_id: nil, throttled_only: nil,
287
305
  request_options: nil)
288
306
  Async do
289
- response = @request_client.conn.get("/v2/transcript") do |req|
307
+ response = @request_client.conn.get do |req|
290
308
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
291
309
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
292
310
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -299,6 +317,7 @@ module AssemblyAI
299
317
  "after_id": after_id,
300
318
  "throttled_only": throttled_only
301
319
  }.compact
320
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
302
321
  end
303
322
  Transcripts::TranscriptList.from_json(json_object: response.body)
304
323
  end
@@ -351,8 +370,9 @@ module AssemblyAI
351
370
  # @return [Transcripts::Transcript]
352
371
  def submit(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil,
353
372
  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)
373
+ deprecate_conformer2(speech_model: speech_model)
354
374
  Async do
355
- response = @request_client.conn.post("/v2/transcript") do |req|
375
+ response = @request_client.conn.post do |req|
356
376
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
357
377
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
358
378
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -397,6 +417,7 @@ module AssemblyAI
397
417
  additional_properties: additional_properties,
398
418
  audio_url: audio_url
399
419
  }.compact
420
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
400
421
  end
401
422
  Transcripts::Transcript.from_json(json_object: response.body)
402
423
  end
@@ -409,10 +430,11 @@ module AssemblyAI
409
430
  # @return [Transcripts::Transcript]
410
431
  def get(transcript_id:, request_options: nil)
411
432
  Async do
412
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}") do |req|
433
+ response = @request_client.conn.get do |req|
413
434
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
414
435
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
415
436
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
437
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}"
416
438
  end
417
439
  Transcripts::Transcript.from_json(json_object: response.body)
418
440
  end
@@ -425,10 +447,11 @@ module AssemblyAI
425
447
  # @return [Transcripts::Transcript]
426
448
  def delete(transcript_id:, request_options: nil)
427
449
  Async do
428
- response = @request_client.conn.delete("/v2/transcript/#{transcript_id}") do |req|
450
+ response = @request_client.conn.delete do |req|
429
451
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
430
452
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
431
453
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
454
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}"
432
455
  end
433
456
  Transcripts::Transcript.from_json(json_object: response.body)
434
457
  end
@@ -443,7 +466,7 @@ module AssemblyAI
443
466
  # @return [String]
444
467
  def get_subtitles(transcript_id:, subtitle_format:, chars_per_caption: nil, request_options: nil)
445
468
  Async do
446
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/#{subtitle_format}") do |req|
469
+ response = @request_client.conn.get do |req|
447
470
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
448
471
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
449
472
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -451,6 +474,7 @@ module AssemblyAI
451
474
  **(request_options&.additional_query_parameters || {}),
452
475
  "chars_per_caption": chars_per_caption
453
476
  }.compact
477
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/#{subtitle_format}"
454
478
  end
455
479
  response.body
456
480
  end
@@ -463,10 +487,11 @@ module AssemblyAI
463
487
  # @return [Transcripts::SentencesResponse]
464
488
  def get_sentences(transcript_id:, request_options: nil)
465
489
  Async do
466
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/sentences") do |req|
490
+ response = @request_client.conn.get do |req|
467
491
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
468
492
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
469
493
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
494
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/sentences"
470
495
  end
471
496
  Transcripts::SentencesResponse.from_json(json_object: response.body)
472
497
  end
@@ -479,10 +504,11 @@ module AssemblyAI
479
504
  # @return [Transcripts::ParagraphsResponse]
480
505
  def get_paragraphs(transcript_id:, request_options: nil)
481
506
  Async do
482
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/paragraphs") do |req|
507
+ response = @request_client.conn.get do |req|
483
508
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
484
509
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
485
510
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
511
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/paragraphs"
486
512
  end
487
513
  Transcripts::ParagraphsResponse.from_json(json_object: response.body)
488
514
  end
@@ -496,11 +522,12 @@ module AssemblyAI
496
522
  # @return [Transcripts::WordSearchResponse]
497
523
  def word_search(transcript_id:, words: nil, request_options: nil)
498
524
  Async do
499
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/word-search") do |req|
525
+ response = @request_client.conn.get do |req|
500
526
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
501
527
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
502
528
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
503
529
  req.params = { **(request_options&.additional_query_parameters || {}), "words": words }.compact
530
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/word-search"
504
531
  end
505
532
  Transcripts::WordSearchResponse.from_json(json_object: response.body)
506
533
  end
@@ -513,13 +540,20 @@ module AssemblyAI
513
540
  # @return [Transcripts::RedactedAudioResponse]
514
541
  def get_redacted_audio(transcript_id:, request_options: nil)
515
542
  Async do
516
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/redacted-audio") do |req|
543
+ response = @request_client.conn.get do |req|
517
544
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
518
545
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
519
546
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
547
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/redacted-audio"
520
548
  end
521
549
  Transcripts::RedactedAudioResponse.from_json(json_object: response.body)
522
550
  end
523
551
  end
552
+
553
+ # @param speech_model [Transcripts::SpeechModel]
554
+ def deprecate_conformer2(speech_model: nil)
555
+ warn "[DEPRECATION] `conformer-2` is deprecated. Please use `best` or `nano` instead." if speech_model == "conformer-2"
556
+ end
557
+ private :deprecate_conformer2
524
558
  end
525
559
  end
@@ -18,11 +18,12 @@ module AssemblyAI
18
18
  # transcript_list = client.transcripts.list(limit: 1)
19
19
  # client.transcripts.list_by_url(url: transcript_list.page_details.next_url)
20
20
  def list_by_url(url: nil, request_options: nil)
21
- url = "/v2/transcript" if url.nil?
22
- response = @request_client.conn.get(url) do |req|
21
+ url = "#{@request_client.get_url(request_options: request_options)}/v2/transcript" if url.nil?
22
+ response = @request_client.conn.get do |req|
23
23
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
24
24
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
25
25
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
26
+ req.url url
26
27
  end
27
28
  Transcripts::TranscriptList.from_json(json_object: response.body)
28
29
  end
@@ -44,11 +45,12 @@ module AssemblyAI
44
45
  # end
45
46
  def list_by_url(url: nil, request_options: nil)
46
47
  Async do
47
- url = "/v2/transcript" if url.nil?
48
- response = @request_client.conn.get(url) do |req|
48
+ url = "#{@request_client.get_url(request_options: request_options)}/v2/transcript" if url.nil?
49
+ response = @request_client.conn.get do |req|
49
50
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
50
51
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
51
52
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
53
+ req.url url
52
54
  end
53
55
  Transcripts::TranscriptList.from_json(json_object: response.body)
54
56
  end
@@ -72,6 +72,7 @@ module AssemblyAI
72
72
  # @return [Transcripts::Transcript]
73
73
  def transcribe(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil,
74
74
  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, polling_options: Transcripts::PollingOptions.new)
75
+ deprecate_conformer2(speech_model: speech_model)
75
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,
76
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)
77
78
  poll_transcript(transcript_id: transcript.id, polling_options: polling_options)
@@ -92,7 +93,11 @@ module AssemblyAI
92
93
  end
93
94
  end
94
95
 
95
- private :poll_transcript
96
+ # @param speech_model [Transcripts::SpeechModel]
97
+ def deprecate_conformer2(speech_model: nil)
98
+ warn "[DEPRECATION] `conformer-2` is deprecated. Please use `best` or `nano` instead." if speech_model == "conformer-2"
99
+ end
100
+ private :poll_transcript, :deprecate_conformer2
96
101
  end
97
102
 
98
103
  # :nodoc:
@@ -146,6 +151,7 @@ module AssemblyAI
146
151
  # @return [Transcripts::Transcript]
147
152
  def transcribe(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil,
148
153
  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, polling_options: Transcripts::PollingOptions.new)
154
+ deprecate_conformer2(speech_model: speech_model)
149
155
  Async do
150
156
  transcript = submit(audio_url: audio_url, speech_model: speech_model, language_code: language_code, punctuate: punctuate, format_text: format_text, dual_channel: dual_channel,
151
157
  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
@@ -170,6 +176,10 @@ module AssemblyAI
170
176
  end
171
177
  end
172
178
 
173
- private :poll_transcript
179
+ # @param speech_model [Transcripts::SpeechModel]
180
+ def deprecate_conformer2(speech_model:)
181
+ warn "[DEPRECATION] `conformer-2` is deprecated. Please use `best` or `nano` instead." if speech_model == "conformer-2"
182
+ end
183
+ private :poll_transcript, :deprecate_conformer2
174
184
  end
175
185
  end
@@ -1,57 +1,78 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "timestamp"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Transcripts
8
9
  class AutoHighlightResult
9
- attr_reader :count, :rank, :text, :timestamps, :additional_properties
10
+ # @return [Integer] The total number of times the key phrase appears in the audio file
11
+ attr_reader :count
12
+ # @return [Float] The total relevancy to the overall audio file of this key phrase - a greater
13
+ # number means more relevant
14
+ attr_reader :rank
15
+ # @return [String] The text itself of the key phrase
16
+ attr_reader :text
17
+ # @return [Array<AssemblyAI::Transcripts::Timestamp>] The timestamp of the of the key phrase
18
+ attr_reader :timestamps
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 count [Integer] The total number of times the key phrase appears in the audio file
12
- # @param rank [Float] The total relevancy to the overall audio file of this key phrase - a greater number means more relevant
28
+ # @param rank [Float] The total relevancy to the overall audio file of this key phrase - a greater
29
+ # number means more relevant
13
30
  # @param text [String] The text itself of the key phrase
14
- # @param timestamps [Array<Transcripts::Timestamp>] The timestamp of the of the key phrase
31
+ # @param timestamps [Array<AssemblyAI::Transcripts::Timestamp>] The timestamp of the of the key phrase
15
32
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
16
- # @return [Transcripts::AutoHighlightResult]
33
+ # @return [AssemblyAI::Transcripts::AutoHighlightResult]
17
34
  def initialize(count:, rank:, text:, timestamps:, additional_properties: nil)
18
- # @type [Integer] The total number of times the key phrase appears in the audio file
19
35
  @count = count
20
- # @type [Float] The total relevancy to the overall audio file of this key phrase - a greater number means more relevant
21
36
  @rank = rank
22
- # @type [String] The text itself of the key phrase
23
37
  @text = text
24
- # @type [Array<Transcripts::Timestamp>] The timestamp of the of the key phrase
25
38
  @timestamps = timestamps
26
- # @type [OpenStruct] Additional properties unmapped to the current class definition
27
39
  @additional_properties = additional_properties
40
+ @_field_set = { "count": count, "rank": rank, "text": text, "timestamps": timestamps }
28
41
  end
29
42
 
30
43
  # Deserialize a JSON object to an instance of AutoHighlightResult
31
44
  #
32
- # @param json_object [JSON]
33
- # @return [Transcripts::AutoHighlightResult]
45
+ # @param json_object [String]
46
+ # @return [AssemblyAI::Transcripts::AutoHighlightResult]
34
47
  def self.from_json(json_object:)
35
48
  struct = JSON.parse(json_object, object_class: OpenStruct)
36
49
  parsed_json = JSON.parse(json_object)
37
- count = struct.count
38
- rank = struct.rank
39
- text = struct.text
50
+ count = struct["count"]
51
+ rank = struct["rank"]
52
+ text = struct["text"]
40
53
  timestamps = parsed_json["timestamps"]&.map do |v|
41
54
  v = v.to_json
42
- Transcripts::Timestamp.from_json(json_object: v)
55
+ AssemblyAI::Transcripts::Timestamp.from_json(json_object: v)
43
56
  end
44
- new(count: count, rank: rank, text: text, timestamps: timestamps, additional_properties: struct)
57
+ new(
58
+ count: count,
59
+ rank: rank,
60
+ text: text,
61
+ timestamps: timestamps,
62
+ additional_properties: struct
63
+ )
45
64
  end
46
65
 
47
66
  # Serialize an instance of AutoHighlightResult to a JSON object
48
67
  #
49
- # @return [JSON]
68
+ # @return [String]
50
69
  def to_json(*_args)
51
- { "count": @count, "rank": @rank, "text": @text, "timestamps": @timestamps }.to_json
70
+ @_field_set&.to_json
52
71
  end
53
72
 
54
- # 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.
73
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
74
+ # hash and check each fields type against the current object's property
75
+ # definitions.
55
76
  #
56
77
  # @param obj [Object]
57
78
  # @return [Void]
@@ -1,51 +1,75 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "audio_intelligence_model_status"
3
4
  require_relative "auto_highlight_result"
5
+ require "ostruct"
4
6
  require "json"
5
7
 
6
8
  module AssemblyAI
7
9
  class Transcripts
8
10
  # An array of results for the Key Phrases model, if it is enabled.
9
- # See [Key phrases](https://www.assemblyai.com/docs/models/key-phrases) for more information.
11
+ # See [Key phrases](https://www.assemblyai.com/docs/models/key-phrases) for more
12
+ # information.
10
13
  class AutoHighlightsResult
11
- attr_reader :results, :additional_properties
14
+ # @return [AssemblyAI::Transcripts::AudioIntelligenceModelStatus] The status of the Key Phrases model. Either success, or unavailable in the rare
15
+ # case that the model failed.
16
+ attr_reader :status
17
+ # @return [Array<AssemblyAI::Transcripts::AutoHighlightResult>] A temporally-sequential array of Key Phrases
18
+ attr_reader :results
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
12
24
 
13
- # @param results [Array<Transcripts::AutoHighlightResult>] A temporally-sequential array of Key Phrases
25
+ OMIT = Object.new
26
+
27
+ # @param status [AssemblyAI::Transcripts::AudioIntelligenceModelStatus] The status of the Key Phrases model. Either success, or unavailable in the rare
28
+ # case that the model failed.
29
+ # @param results [Array<AssemblyAI::Transcripts::AutoHighlightResult>] A temporally-sequential array of Key Phrases
14
30
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
15
- # @return [Transcripts::AutoHighlightsResult]
16
- def initialize(results:, additional_properties: nil)
17
- # @type [Array<Transcripts::AutoHighlightResult>] A temporally-sequential array of Key Phrases
31
+ # @return [AssemblyAI::Transcripts::AutoHighlightsResult]
32
+ def initialize(status:, results:, additional_properties: nil)
33
+ @status = status
18
34
  @results = results
19
- # @type [OpenStruct] Additional properties unmapped to the current class definition
20
35
  @additional_properties = additional_properties
36
+ @_field_set = { "status": status, "results": results }
21
37
  end
22
38
 
23
39
  # Deserialize a JSON object to an instance of AutoHighlightsResult
24
40
  #
25
- # @param json_object [JSON]
26
- # @return [Transcripts::AutoHighlightsResult]
41
+ # @param json_object [String]
42
+ # @return [AssemblyAI::Transcripts::AutoHighlightsResult]
27
43
  def self.from_json(json_object:)
28
44
  struct = JSON.parse(json_object, object_class: OpenStruct)
29
45
  parsed_json = JSON.parse(json_object)
46
+ status = struct["status"]
30
47
  results = parsed_json["results"]&.map do |v|
31
48
  v = v.to_json
32
- Transcripts::AutoHighlightResult.from_json(json_object: v)
49
+ AssemblyAI::Transcripts::AutoHighlightResult.from_json(json_object: v)
33
50
  end
34
- new(results: results, additional_properties: struct)
51
+ new(
52
+ status: status,
53
+ results: results,
54
+ additional_properties: struct
55
+ )
35
56
  end
36
57
 
37
58
  # Serialize an instance of AutoHighlightsResult to a JSON object
38
59
  #
39
- # @return [JSON]
60
+ # @return [String]
40
61
  def to_json(*_args)
41
- { "results": @results }.to_json
62
+ @_field_set&.to_json
42
63
  end
43
64
 
44
- # 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.
65
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
66
+ # hash and check each fields type against the current object's property
67
+ # definitions.
45
68
  #
46
69
  # @param obj [Object]
47
70
  # @return [Void]
48
71
  def self.validate_raw(obj:)
72
+ obj.status.is_a?(AssemblyAI::Transcripts::AudioIntelligenceModelStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
49
73
  obj.results.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.")
50
74
  end
51
75
  end