assemblyai 1.0.0.pre.beta.7 → 1.0.0.pre.beta.9

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 +260 -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 -55
  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 -32
  10. data/lib/assemblyai/lemur/types/lemur_question_answer.rb +28 -14
  11. data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +29 -15
  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 +30 -14
  17. data/lib/assemblyai/realtime/types/configure_end_utterance_silence_threshold.rb +24 -13
  18. data/lib/assemblyai/realtime/types/final_transcript.rb +73 -42
  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 +63 -35
  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 +20 -11
  27. data/lib/assemblyai/realtime/types/realtime_transcript.rb +15 -9
  28. data/lib/assemblyai/realtime/types/session_begins.rb +32 -15
  29. data/lib/assemblyai/realtime/types/session_information.rb +69 -0
  30. data/lib/assemblyai/realtime/types/session_terminated.rb +21 -12
  31. data/lib/assemblyai/realtime/types/terminate_session.rb +20 -11
  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/{realtime → streaming}/types/send_message.rb +26 -14
  35. data/lib/assemblyai/streaming/types/streaming.rb +11 -0
  36. data/lib/assemblyai/transcripts/client.rb +50 -18
  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/entity_type.rb +15 -0
  47. data/lib/assemblyai/transcripts/types/page_details.rb +62 -36
  48. data/lib/assemblyai/transcripts/types/paragraphs_response.rb +37 -19
  49. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +4 -1
  50. data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +29 -15
  51. data/lib/assemblyai/transcripts/types/sentences_response.rb +37 -19
  52. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +63 -36
  53. data/lib/assemblyai/transcripts/types/severity_score_summary.rb +32 -16
  54. data/lib/assemblyai/transcripts/types/speech_model.rb +1 -0
  55. data/lib/assemblyai/transcripts/types/substitution_policy.rb +3 -1
  56. data/lib/assemblyai/transcripts/types/timestamp.rb +28 -14
  57. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +39 -20
  58. data/lib/assemblyai/transcripts/types/topic_detection_result.rb +40 -21
  59. data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +31 -15
  60. data/lib/assemblyai/transcripts/types/transcript.rb +513 -295
  61. data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +30 -15
  62. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +87 -4
  63. data/lib/assemblyai/transcripts/types/transcript_list.rb +33 -17
  64. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +60 -35
  65. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +338 -196
  66. data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +61 -34
  67. data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +30 -16
  68. data/lib/assemblyai/transcripts/types/transcript_sentence.rb +61 -34
  69. data/lib/assemblyai/transcripts/types/transcript_status.rb +2 -1
  70. data/lib/assemblyai/transcripts/types/transcript_utterance.rb +55 -32
  71. data/lib/assemblyai/transcripts/types/transcript_word.rb +55 -24
  72. data/lib/assemblyai/transcripts/types/word_search_match.rb +40 -20
  73. data/lib/assemblyai/transcripts/types/word_search_response.rb +36 -17
  74. data/lib/assemblyai/types/error.rb +32 -16
  75. data/lib/requests.rb +80 -34
  76. data/lib/types_export.rb +4 -3
  77. metadata +6 -5
  78. data/lib/assemblyai/realtime/types/audio_data.rb +0 -7
  79. data/lib/assemblyai/realtime/types/receive_message.rb +0 -87
@@ -44,7 +44,7 @@ module AssemblyAI
44
44
  # @return [Transcripts::TranscriptList]
45
45
  def list(limit: nil, status: nil, created_on: nil, before_id: nil, after_id: nil, throttled_only: nil,
46
46
  request_options: nil)
47
- response = @request_client.conn.get("/v2/transcript") do |req|
47
+ response = @request_client.conn.get do |req|
48
48
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
49
49
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
50
50
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -57,6 +57,7 @@ module AssemblyAI
57
57
  "after_id": after_id,
58
58
  "throttled_only": throttled_only
59
59
  }.compact
60
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
60
61
  end
61
62
  Transcripts::TranscriptList.from_json(json_object: response.body)
62
63
  end
@@ -108,7 +109,8 @@ module AssemblyAI
108
109
  # @return [Transcripts::Transcript]
109
110
  def submit(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil,
110
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)
111
- response = @request_client.conn.post("/v2/transcript") do |req|
112
+ deprecate_conformer2(speech_model: speech_model)
113
+ response = @request_client.conn.post do |req|
112
114
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
113
115
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
114
116
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -153,6 +155,7 @@ module AssemblyAI
153
155
  additional_properties: additional_properties,
154
156
  audio_url: audio_url
155
157
  }.compact
158
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
156
159
  end
157
160
  Transcripts::Transcript.from_json(json_object: response.body)
158
161
  end
@@ -163,10 +166,11 @@ module AssemblyAI
163
166
  # @param request_options [RequestOptions]
164
167
  # @return [Transcripts::Transcript]
165
168
  def get(transcript_id:, request_options: nil)
166
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}") do |req|
169
+ response = @request_client.conn.get do |req|
167
170
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
168
171
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
169
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}"
170
174
  end
171
175
  Transcripts::Transcript.from_json(json_object: response.body)
172
176
  end
@@ -177,10 +181,11 @@ module AssemblyAI
177
181
  # @param request_options [RequestOptions]
178
182
  # @return [Transcripts::Transcript]
179
183
  def delete(transcript_id:, request_options: nil)
180
- response = @request_client.conn.delete("/v2/transcript/#{transcript_id}") do |req|
184
+ response = @request_client.conn.delete do |req|
181
185
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
182
186
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
183
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}"
184
189
  end
185
190
  Transcripts::Transcript.from_json(json_object: response.body)
186
191
  end
@@ -193,7 +198,7 @@ module AssemblyAI
193
198
  # @param request_options [RequestOptions]
194
199
  # @return [String]
195
200
  def get_subtitles(transcript_id:, subtitle_format:, chars_per_caption: nil, request_options: nil)
196
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/#{subtitle_format}") do |req|
201
+ response = @request_client.conn.get do |req|
197
202
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
198
203
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
199
204
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -201,6 +206,7 @@ module AssemblyAI
201
206
  **(request_options&.additional_query_parameters || {}),
202
207
  "chars_per_caption": chars_per_caption
203
208
  }.compact
209
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/#{subtitle_format}"
204
210
  end
205
211
  response.body
206
212
  end
@@ -211,10 +217,11 @@ module AssemblyAI
211
217
  # @param request_options [RequestOptions]
212
218
  # @return [Transcripts::SentencesResponse]
213
219
  def get_sentences(transcript_id:, request_options: nil)
214
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/sentences") do |req|
220
+ response = @request_client.conn.get do |req|
215
221
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
216
222
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
217
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"
218
225
  end
219
226
  Transcripts::SentencesResponse.from_json(json_object: response.body)
220
227
  end
@@ -225,10 +232,11 @@ module AssemblyAI
225
232
  # @param request_options [RequestOptions]
226
233
  # @return [Transcripts::ParagraphsResponse]
227
234
  def get_paragraphs(transcript_id:, request_options: nil)
228
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/paragraphs") do |req|
235
+ response = @request_client.conn.get do |req|
229
236
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
230
237
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
231
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"
232
240
  end
233
241
  Transcripts::ParagraphsResponse.from_json(json_object: response.body)
234
242
  end
@@ -240,11 +248,12 @@ module AssemblyAI
240
248
  # @param request_options [RequestOptions]
241
249
  # @return [Transcripts::WordSearchResponse]
242
250
  def word_search(transcript_id:, words: nil, request_options: nil)
243
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/word-search") do |req|
251
+ response = @request_client.conn.get do |req|
244
252
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
245
253
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
246
254
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
247
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"
248
257
  end
249
258
  Transcripts::WordSearchResponse.from_json(json_object: response.body)
250
259
  end
@@ -255,13 +264,20 @@ module AssemblyAI
255
264
  # @param request_options [RequestOptions]
256
265
  # @return [Transcripts::RedactedAudioResponse]
257
266
  def get_redacted_audio(transcript_id:, request_options: nil)
258
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/redacted-audio") do |req|
267
+ response = @request_client.conn.get do |req|
259
268
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
260
269
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
261
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"
262
272
  end
263
273
  Transcripts::RedactedAudioResponse.from_json(json_object: response.body)
264
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
265
281
  end
266
282
 
267
283
  class AsyncTranscriptsClient
@@ -288,7 +304,7 @@ module AssemblyAI
288
304
  def list(limit: nil, status: nil, created_on: nil, before_id: nil, after_id: nil, throttled_only: nil,
289
305
  request_options: nil)
290
306
  Async do
291
- response = @request_client.conn.get("/v2/transcript") do |req|
307
+ response = @request_client.conn.get do |req|
292
308
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
293
309
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
294
310
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -301,6 +317,7 @@ module AssemblyAI
301
317
  "after_id": after_id,
302
318
  "throttled_only": throttled_only
303
319
  }.compact
320
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
304
321
  end
305
322
  Transcripts::TranscriptList.from_json(json_object: response.body)
306
323
  end
@@ -353,8 +370,9 @@ module AssemblyAI
353
370
  # @return [Transcripts::Transcript]
354
371
  def submit(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil,
355
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)
356
374
  Async do
357
- response = @request_client.conn.post("/v2/transcript") do |req|
375
+ response = @request_client.conn.post do |req|
358
376
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
359
377
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
360
378
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -399,6 +417,7 @@ module AssemblyAI
399
417
  additional_properties: additional_properties,
400
418
  audio_url: audio_url
401
419
  }.compact
420
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
402
421
  end
403
422
  Transcripts::Transcript.from_json(json_object: response.body)
404
423
  end
@@ -411,10 +430,11 @@ module AssemblyAI
411
430
  # @return [Transcripts::Transcript]
412
431
  def get(transcript_id:, request_options: nil)
413
432
  Async do
414
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}") do |req|
433
+ response = @request_client.conn.get do |req|
415
434
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
416
435
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
417
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}"
418
438
  end
419
439
  Transcripts::Transcript.from_json(json_object: response.body)
420
440
  end
@@ -427,10 +447,11 @@ module AssemblyAI
427
447
  # @return [Transcripts::Transcript]
428
448
  def delete(transcript_id:, request_options: nil)
429
449
  Async do
430
- response = @request_client.conn.delete("/v2/transcript/#{transcript_id}") do |req|
450
+ response = @request_client.conn.delete do |req|
431
451
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
432
452
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
433
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}"
434
455
  end
435
456
  Transcripts::Transcript.from_json(json_object: response.body)
436
457
  end
@@ -445,7 +466,7 @@ module AssemblyAI
445
466
  # @return [String]
446
467
  def get_subtitles(transcript_id:, subtitle_format:, chars_per_caption: nil, request_options: nil)
447
468
  Async do
448
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/#{subtitle_format}") do |req|
469
+ response = @request_client.conn.get do |req|
449
470
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
450
471
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
451
472
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -453,6 +474,7 @@ module AssemblyAI
453
474
  **(request_options&.additional_query_parameters || {}),
454
475
  "chars_per_caption": chars_per_caption
455
476
  }.compact
477
+ req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/#{subtitle_format}"
456
478
  end
457
479
  response.body
458
480
  end
@@ -465,10 +487,11 @@ module AssemblyAI
465
487
  # @return [Transcripts::SentencesResponse]
466
488
  def get_sentences(transcript_id:, request_options: nil)
467
489
  Async do
468
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/sentences") do |req|
490
+ response = @request_client.conn.get do |req|
469
491
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
470
492
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
471
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"
472
495
  end
473
496
  Transcripts::SentencesResponse.from_json(json_object: response.body)
474
497
  end
@@ -481,10 +504,11 @@ module AssemblyAI
481
504
  # @return [Transcripts::ParagraphsResponse]
482
505
  def get_paragraphs(transcript_id:, request_options: nil)
483
506
  Async do
484
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/paragraphs") do |req|
507
+ response = @request_client.conn.get do |req|
485
508
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
486
509
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
487
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"
488
512
  end
489
513
  Transcripts::ParagraphsResponse.from_json(json_object: response.body)
490
514
  end
@@ -498,11 +522,12 @@ module AssemblyAI
498
522
  # @return [Transcripts::WordSearchResponse]
499
523
  def word_search(transcript_id:, words: nil, request_options: nil)
500
524
  Async do
501
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/word-search") do |req|
525
+ response = @request_client.conn.get do |req|
502
526
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
503
527
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
504
528
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
505
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"
506
531
  end
507
532
  Transcripts::WordSearchResponse.from_json(json_object: response.body)
508
533
  end
@@ -515,13 +540,20 @@ module AssemblyAI
515
540
  # @return [Transcripts::RedactedAudioResponse]
516
541
  def get_redacted_audio(transcript_id:, request_options: nil)
517
542
  Async do
518
- response = @request_client.conn.get("/v2/transcript/#{transcript_id}/redacted-audio") do |req|
543
+ response = @request_client.conn.get do |req|
519
544
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
520
545
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
521
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"
522
548
  end
523
549
  Transcripts::RedactedAudioResponse.from_json(json_object: response.body)
524
550
  end
525
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
526
558
  end
527
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
@@ -1,12 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Transcripts
7
8
  # Chapter of the audio file
8
9
  class Chapter
9
- attr_reader :gist, :headline, :summary, :start, :end_, :additional_properties
10
+ # @return [String] An ultra-short summary (just a few words) of the content spoken in the chapter
11
+ attr_reader :gist
12
+ # @return [String] A single sentence summary of the content spoken during the chapter
13
+ attr_reader :headline
14
+ # @return [String] A one paragraph summary of the content spoken during the chapter
15
+ attr_reader :summary
16
+ # @return [Integer] The starting time, in milliseconds, for the chapter
17
+ attr_reader :start
18
+ # @return [Integer] The starting time, in milliseconds, for the chapter
19
+ attr_reader :end_
20
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
21
+ attr_reader :additional_properties
22
+ # @return [Object]
23
+ attr_reader :_field_set
24
+ protected :_field_set
25
+
26
+ OMIT = Object.new
10
27
 
11
28
  # @param gist [String] An ultra-short summary (just a few words) of the content spoken in the chapter
12
29
  # @param headline [String] A single sentence summary of the content spoken during the chapter
@@ -14,45 +31,48 @@ module AssemblyAI
14
31
  # @param start [Integer] The starting time, in milliseconds, for the chapter
15
32
  # @param end_ [Integer] The starting time, in milliseconds, for the chapter
16
33
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
17
- # @return [Transcripts::Chapter]
34
+ # @return [AssemblyAI::Transcripts::Chapter]
18
35
  def initialize(gist:, headline:, summary:, start:, end_:, additional_properties: nil)
19
- # @type [String] An ultra-short summary (just a few words) of the content spoken in the chapter
20
36
  @gist = gist
21
- # @type [String] A single sentence summary of the content spoken during the chapter
22
37
  @headline = headline
23
- # @type [String] A one paragraph summary of the content spoken during the chapter
24
38
  @summary = summary
25
- # @type [Integer] The starting time, in milliseconds, for the chapter
26
39
  @start = start
27
- # @type [Integer] The starting time, in milliseconds, for the chapter
28
40
  @end_ = end_
29
- # @type [OpenStruct] Additional properties unmapped to the current class definition
30
41
  @additional_properties = additional_properties
42
+ @_field_set = { "gist": gist, "headline": headline, "summary": summary, "start": start, "end": end_ }
31
43
  end
32
44
 
33
45
  # Deserialize a JSON object to an instance of Chapter
34
46
  #
35
- # @param json_object [JSON]
36
- # @return [Transcripts::Chapter]
47
+ # @param json_object [String]
48
+ # @return [AssemblyAI::Transcripts::Chapter]
37
49
  def self.from_json(json_object:)
38
50
  struct = JSON.parse(json_object, object_class: OpenStruct)
39
- JSON.parse(json_object)
40
- gist = struct.gist
41
- headline = struct.headline
42
- summary = struct.summary
43
- start = struct.start
44
- end_ = struct.end
45
- new(gist: gist, headline: headline, summary: summary, start: start, end_: end_, additional_properties: struct)
51
+ gist = struct["gist"]
52
+ headline = struct["headline"]
53
+ summary = struct["summary"]
54
+ start = struct["start"]
55
+ end_ = struct["end"]
56
+ new(
57
+ gist: gist,
58
+ headline: headline,
59
+ summary: summary,
60
+ start: start,
61
+ end_: end_,
62
+ additional_properties: struct
63
+ )
46
64
  end
47
65
 
48
66
  # Serialize an instance of Chapter to a JSON object
49
67
  #
50
- # @return [JSON]
68
+ # @return [String]
51
69
  def to_json(*_args)
52
- { "gist": @gist, "headline": @headline, "summary": @summary, "start": @start, "end": @end_ }.to_json
70
+ @_field_set&.to_json
53
71
  end
54
72
 
55
- # 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.
56
76
  #
57
77
  # @param obj [Object]
58
78
  # @return [Void]