Class: AssemblyAI::AsyncTranscriptsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/assemblyai/transcripts/polling_client.rb,
lib/assemblyai/transcripts/client.rb,
lib/assemblyai/transcripts/list_by_url_client.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ AsyncTranscriptsClient

Parameters:



281
282
283
284
# File 'lib/assemblyai/transcripts/client.rb', line 281

def initialize(request_client:)
  # @type [AsyncRequestClient]
  @request_client = request_client
end

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



277
278
279
# File 'lib/assemblyai/transcripts/client.rb', line 277

def request_client
  @request_client
end

Instance Method Details

#delete(transcript_id:, request_options: nil) ⇒ Transcripts::Transcript

Delete the transcript

Parameters:

  • transcript_id (String)

    ID of the transcript

  • request_options (RequestOptions) (defaults to: nil)

Returns:



440
441
442
443
444
445
446
447
448
449
450
# File 'lib/assemblyai/transcripts/client.rb', line 440

def delete(transcript_id:, request_options: nil)
  Async do
    response = @request_client.conn.delete do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}"
    end
    Transcripts::Transcript.from_json(json_object: response.body)
  end
end

#get(transcript_id:, request_options: nil) ⇒ Transcripts::Transcript

Get the transcript resource. The transcript is ready when the “status” is “completed”.

Parameters:

  • transcript_id (String)

    ID of the transcript

  • request_options (RequestOptions) (defaults to: nil)

Returns:



423
424
425
426
427
428
429
430
431
432
433
# File 'lib/assemblyai/transcripts/client.rb', line 423

def get(transcript_id:, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}"
    end
    Transcripts::Transcript.from_json(json_object: response.body)
  end
end

#get_paragraphs(transcript_id:, request_options: nil) ⇒ Transcripts::ParagraphsResponse

Get the transcript split by paragraphs. The API will attempt to semantically segment your transcript into paragraphs to create more reader-friendly transcripts.

Parameters:

  • transcript_id (String)

    ID of the transcript

  • request_options (RequestOptions) (defaults to: nil)

Returns:



497
498
499
500
501
502
503
504
505
506
507
# File 'lib/assemblyai/transcripts/client.rb', line 497

def get_paragraphs(transcript_id:, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/paragraphs"
    end
    Transcripts::ParagraphsResponse.from_json(json_object: response.body)
  end
end

#get_redacted_audio(transcript_id:, request_options: nil) ⇒ Transcripts::RedactedAudioResponse

Retrieve the redacted audio object containing the status and URL to the redacted audio.

Parameters:

  • transcript_id (String)

    ID of the transcript

  • request_options (RequestOptions) (defaults to: nil)

Returns:



533
534
535
536
537
538
539
540
541
542
543
# File 'lib/assemblyai/transcripts/client.rb', line 533

def get_redacted_audio(transcript_id:, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/redacted-audio"
    end
    Transcripts::RedactedAudioResponse.from_json(json_object: response.body)
  end
end

#get_sentences(transcript_id:, request_options: nil) ⇒ Transcripts::SentencesResponse

Get the transcript split by sentences. The API will attempt to semantically segment the transcript into sentences to create more reader-friendly transcripts.

Parameters:

  • transcript_id (String)

    ID of the transcript

  • request_options (RequestOptions) (defaults to: nil)

Returns:



480
481
482
483
484
485
486
487
488
489
490
# File 'lib/assemblyai/transcripts/client.rb', line 480

def get_sentences(transcript_id:, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/sentences"
    end
    Transcripts::SentencesResponse.from_json(json_object: response.body)
  end
end

#get_subtitles(transcript_id:, subtitle_format:, chars_per_caption: nil, request_options: nil) ⇒ String

Export your transcript in SRT or VTT format, to be plugged into a video player for subtitles and closed captions.

Parameters:

  • transcript_id (String)

    ID of the transcript

  • subtitle_format (Transcripts::SubtitleFormat)

    The format of the captions

  • chars_per_caption (Integer) (defaults to: nil)

    The maximum number of characters per caption

  • request_options (RequestOptions) (defaults to: nil)

Returns:

  • (String)


459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'lib/assemblyai/transcripts/client.rb', line 459

def get_subtitles(transcript_id:, subtitle_format:, chars_per_caption: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.params = {
        **(request_options&.additional_query_parameters || {}),
        "chars_per_caption": chars_per_caption
      }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/#{subtitle_format}"
    end
    response.body
  end
end

#list(limit: nil, status: nil, created_on: nil, before_id: nil, after_id: nil, throttled_only: nil, request_options: nil) ⇒ Transcripts::TranscriptList

Retrieve a list of transcripts you created. Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.

Parameters:

  • limit (Integer) (defaults to: nil)

    Maximum amount of transcripts to retrieve

  • status (Transcripts::TranscriptStatus) (defaults to: nil)

    Filter by transcript status

  • created_on (String) (defaults to: nil)

    Only get transcripts created on this date

  • before_id (String) (defaults to: nil)

    Get transcripts that were created before this transcript ID

  • after_id (String) (defaults to: nil)

    Get transcripts that were created after this transcript ID

  • throttled_only (Boolean) (defaults to: nil)

    Only get throttled transcripts, overrides the status filter

  • request_options (RequestOptions) (defaults to: nil)

Returns:



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/assemblyai/transcripts/client.rb', line 297

def list(limit: nil, status: nil, created_on: nil, before_id: nil, after_id: nil, throttled_only: nil,
         request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.params = {
        **(request_options&.additional_query_parameters || {}),
        "limit": limit,
        "status": status,
        "created_on": created_on,
        "before_id": before_id,
        "after_id": after_id,
        "throttled_only": throttled_only
      }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
    end
    Transcripts::TranscriptList.from_json(json_object: response.body)
  end
end

#list_by_url(url: nil, request_options: nil) ⇒ Transcripts::TranscriptList

Retrieve a list of transcripts you created

Examples:

Retrieve the next page of results

client = AssemblyAI::AsyncClient.new(api_key: "YOUR_API_KEY")
Sync do
  transcript_list = client.transcripts.list(limit: 1).wait
  client.transcripts.list_by_url(url: transcript_list.page_details.next_url)
end

Parameters:

  • url (String) (defaults to: nil)

    The URL to retrieve the transcript list from

  • request_options (RequestOptions) (defaults to: nil)

Returns:



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/assemblyai/transcripts/list_by_url_client.rb', line 46

def list_by_url(url: nil, request_options: nil)
  Async do
    url = "#{@request_client.get_url(request_options: request_options)}/v2/transcript" if url.nil?
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.url url
    end
    Transcripts::TranscriptList.from_json(json_object: response.body)
  end
end

#submit(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil, 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) ⇒ Transcripts::Transcript

Create a transcript from an audio or video file that is accessible via a URL.

Parameters:

  • speech_model (Transcripts::SpeechModel) (defaults to: nil)
  • language_code (Transcripts::TranscriptLanguageCode) (defaults to: nil)
  • punctuate (Boolean) (defaults to: nil)

    Enable Automatic Punctuation, can be true or false

  • format_text (Boolean) (defaults to: nil)

    Enable Text Formatting, can be true or false

  • dual_channel (Boolean) (defaults to: nil)

    Enable [Dual Channel](www.assemblyai.com/docs/models/speech-recognition#dual-channel-transcription) transcription, can be true or false.

  • webhook_url (String) (defaults to: nil)

    The URL to which AssemblyAI send webhooks upon trancription completion

  • webhook_auth_header_name (String) (defaults to: nil)

    The header name which should be sent back with webhook calls

  • webhook_auth_header_value (String) (defaults to: nil)

    Specify a header name and value to send back with a webhook call for added security

  • auto_highlights (Boolean) (defaults to: nil)

    Whether Key Phrases is enabled, either true or false

  • audio_start_from (Integer) (defaults to: nil)

    The point in time, in milliseconds, to begin transcribing in your media file

  • audio_end_at (Integer) (defaults to: nil)

    The point in time, in milliseconds, to stop transcribing in your media file

  • word_boost (Array<String>) (defaults to: nil)

    The list of custom vocabulary to boost transcription probability for

  • boost_param (Transcripts::TranscriptBoostParam) (defaults to: nil)

    The word boost parameter value

  • filter_profanity (Boolean) (defaults to: nil)

    Filter profanity from the transcribed text, can be true or false

  • redact_pii (Boolean) (defaults to: nil)

    Redact PII from the transcribed text using the Redact PII model, can be true or false

  • redact_pii_audio (Boolean) (defaults to: nil)

    Generate a copy of the original media file with spoken PII “beeped” out, can be true or false. See [PII redaction](www.assemblyai.com/docs/models/pii-redaction) for more details.

  • redact_pii_audio_quality (Transcripts::RedactPiiAudioQuality) (defaults to: nil)

    Controls the filetype of the audio created by redact_pii_audio. Currently supports mp3 (default) and wav. See [PII redaction](www.assemblyai.com/docs/models/pii-redaction) for more details.

  • redact_pii_policies (Array<Transcripts::PiiPolicy>) (defaults to: nil)

    The list of PII Redaction policies to enable. See [PII redaction](www.assemblyai.com/docs/models/pii-redaction) for more details.

  • redact_pii_sub (Transcripts::SubstitutionPolicy) (defaults to: nil)
  • speaker_labels (Boolean) (defaults to: nil)

    Enable [Speaker diarization](www.assemblyai.com/docs/models/speaker-diarization), can be true or false

  • speakers_expected (Integer) (defaults to: nil)

    Tells the speaker label model how many speakers it should attempt to identify, up to 10. See [Speaker diarization](www.assemblyai.com/docs/models/speaker-diarization) for more details.

  • content_safety (Boolean) (defaults to: nil)

    Enable [Content Moderation](www.assemblyai.com/docs/models/content-moderation), can be true or false

  • content_safety_confidence (Integer) (defaults to: nil)

    The confidence threshold for content moderation. Values must be between 25 and 100.

  • iab_categories (Boolean) (defaults to: nil)

    Enable [Topic Detection](www.assemblyai.com/docs/models/topic-detection), can be true or false

  • language_detection (Boolean) (defaults to: nil)

    Whether [Automatic language detection](www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection) was enabled in the transcription request, either true or false.

  • custom_spelling (Array<Hash>) (defaults to: nil)

    Customize how words are spelled and formatted using to and from valuesRequest of type Array<Transcripts::TranscriptCustomSpelling>, as a Hash

    • :from (Array<String>)

    • :to (String)

  • disfluencies (Boolean) (defaults to: nil)

    Transcribe Filler Words, like “umm”, in your media file; can be true or false

  • sentiment_analysis (Boolean) (defaults to: nil)

    Enable [Sentiment Analysis](www.assemblyai.com/docs/models/sentiment-analysis), can be true or false

  • auto_chapters (Boolean) (defaults to: nil)

    Enable [Auto Chapters](www.assemblyai.com/docs/models/auto-chapters), can be true or false

  • entity_detection (Boolean) (defaults to: nil)

    Enable [Entity Detection](www.assemblyai.com/docs/models/entity-detection), can be true or false

  • speech_threshold (Float) (defaults to: nil)

    Reject audio files that contain less than this fraction of speech. Valid values are in the range [0, 1] inclusive.

  • summarization (Boolean) (defaults to: nil)

    Enable [Summarization](www.assemblyai.com/docs/models/summarization), can be true or false

  • summary_model (Transcripts::SummaryModel) (defaults to: nil)

    The model to summarize the transcript

  • summary_type (Transcripts::SummaryType) (defaults to: nil)

    The type of summary

  • custom_topics (Boolean) (defaults to: nil)

    Whether custom topics is enabled, either true or false

  • topics (Array<String>) (defaults to: nil)

    The list of custom topics provided, if custom topics is enabled

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition

  • audio_url (String)

    The URL of the audio or video file to transcribe.

  • request_options (RequestOptions) (defaults to: nil)

Returns:



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/assemblyai/transcripts/client.rb', line 364

def submit(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil,
           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)
  Async do
    response = @request_client.conn.post do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.body = {
        **(request_options&.additional_body_parameters || {}),
        speech_model: speech_model,
        language_code: language_code,
        punctuate: punctuate,
        format_text: format_text,
        dual_channel: dual_channel,
        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,
        audio_url: audio_url
      }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
    end
    Transcripts::Transcript.from_json(json_object: response.body)
  end
end

#transcribe(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil, 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) ⇒ Transcripts::Transcript

Create a transcript from an audio or video file that is accessible via a URL. .transcribe polls for completion of the transcription, while the .submit function does not.

Parameters:

  • speech_model (Transcripts::SpeechModel) (defaults to: nil)
  • language_code (Transcripts::TranscriptLanguageCode) (defaults to: nil)
  • punctuate (Boolean) (defaults to: nil)

    Enable Automatic Punctuation, can be true or false

  • format_text (Boolean) (defaults to: nil)

    Enable Text Formatting, can be true or false

  • dual_channel (Boolean) (defaults to: nil)

    Enable [Dual Channel](www.assemblyai.com/docs/models/speech-recognition#dual-channel-transcription) transcription, can be true or false.

  • webhook_url (String) (defaults to: nil)

    The URL to which AssemblyAI send webhooks upon trancription completion

  • webhook_auth_header_name (String) (defaults to: nil)

    The header name which should be sent back with webhook calls

  • webhook_auth_header_value (String) (defaults to: nil)

    Specify a header name and value to send back with a webhook call for added security

  • auto_highlights (Boolean) (defaults to: nil)

    Whether Key Phrases is enabled, either true or false

  • audio_start_from (Integer) (defaults to: nil)

    The point in time, in milliseconds, to begin transcribing in your media file

  • audio_end_at (Integer) (defaults to: nil)

    The point in time, in milliseconds, to stop transcribing in your media file

  • word_boost (Array<String>) (defaults to: nil)

    The list of custom vocabulary to boost transcription probability for

  • boost_param (Transcripts::TranscriptBoostParam) (defaults to: nil)

    The word boost parameter value

  • filter_profanity (Boolean) (defaults to: nil)

    Filter profanity from the transcribed text, can be true or false

  • redact_pii (Boolean) (defaults to: nil)

    Redact PII from the transcribed text using the Redact PII model, can be true or false

  • redact_pii_audio (Boolean) (defaults to: nil)

    Generate a copy of the original media file with spoken PII “beeped” out, can be true or false. See [PII redaction](www.assemblyai.com/docs/models/pii-redaction) for more details.

  • redact_pii_audio_quality (Transcripts::RedactPiiAudioQuality) (defaults to: nil)

    Controls the filetype of the audio created by redact_pii_audio. Currently supports mp3 (default) and wav. See [PII redaction](www.assemblyai.com/docs/models/pii-redaction) for more details.

  • redact_pii_policies (Array<Transcripts::PiiPolicy>) (defaults to: nil)

    The list of PII Redaction policies to enable. See [PII redaction](www.assemblyai.com/docs/models/pii-redaction) for more details.

  • redact_pii_sub (Transcripts::SubstitutionPolicy) (defaults to: nil)
  • speaker_labels (Boolean) (defaults to: nil)

    Enable [Speaker diarization](www.assemblyai.com/docs/models/speaker-diarization), can be true or false

  • speakers_expected (Integer) (defaults to: nil)

    Tells the speaker label model how many speakers it should attempt to identify, up to 10. See [Speaker diarization](www.assemblyai.com/docs/models/speaker-diarization) for more details.

  • content_safety (Boolean) (defaults to: nil)

    Enable [Content Moderation](www.assemblyai.com/docs/models/content-moderation), can be true or false

  • content_safety_confidence (Integer) (defaults to: nil)

    The confidence threshold for content moderation. Values must be between 25 and 100.

  • iab_categories (Boolean) (defaults to: nil)

    Enable [Topic Detection](www.assemblyai.com/docs/models/topic-detection), can be true or false

  • language_detection (Boolean) (defaults to: nil)

    Whether [Automatic language detection](www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection) was enabled in the transcription request, either true or false.

  • custom_spelling (Array<Hash>) (defaults to: nil)

    Customize how words are spelled and formatted using to and from valuesRequest of type Array<Transcripts::TranscriptCustomSpelling>, as a Hash

    • :from (Array<String>)

    • :to (String)

  • disfluencies (Boolean) (defaults to: nil)

    Transcribe Filler Words, like “umm”, in your media file; can be true or false

  • sentiment_analysis (Boolean) (defaults to: nil)

    Enable [Sentiment Analysis](www.assemblyai.com/docs/models/sentiment-analysis), can be true or false

  • auto_chapters (Boolean) (defaults to: nil)

    Enable [Auto Chapters](www.assemblyai.com/docs/models/auto-chapters), can be true or false

  • entity_detection (Boolean) (defaults to: nil)

    Enable [Entity Detection](www.assemblyai.com/docs/models/entity-detection), can be true or false

  • speech_threshold (Float) (defaults to: nil)

    Reject audio files that contain less than this fraction of speech. Valid values are in the range [0, 1] inclusive.

  • summarization (Boolean) (defaults to: nil)

    Enable [Summarization](www.assemblyai.com/docs/models/summarization), can be true or false

  • summary_model (Transcripts::SummaryModel) (defaults to: nil)

    The model to summarize the transcript

  • summary_type (Transcripts::SummaryType) (defaults to: nil)

    The type of summary

  • custom_topics (Boolean) (defaults to: nil)

    Whether custom topics is enabled, either true or false

  • topics (Array<String>) (defaults to: nil)

    The list of custom topics provided, if custom topics is enabled

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition

  • audio_url (String)

    The URL of the audio or video file to transcribe.

  • request_options (RequestOptions) (defaults to: nil)
  • polling_options (Transcripts::PollingOptions) (defaults to: Transcripts::PollingOptions.new)

    Configuration options for polling requests.

Returns:



150
151
152
153
154
155
156
157
# File 'lib/assemblyai/transcripts/polling_client.rb', line 150

def transcribe(audio_url:, speech_model: nil, language_code: nil, punctuate: nil, format_text: nil, dual_channel: nil,
               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)
  Async do
    transcript = submit(audio_url: audio_url, speech_model: speech_model, language_code: language_code, punctuate: punctuate, format_text: format_text, dual_channel: dual_channel,
                        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
    wait_until_ready(transcript_id: transcript.id, polling_options: polling_options).wait
  end
end

#wait_until_ready(transcript_id:, polling_options: Transcripts::PollingOptions.new) ⇒ Transcripts::Transcript

Wait until the transcript is ready. The transcript is ready when the “status” is “completed”.

Parameters:

  • transcript_id (String)

    ID of the transcript

  • polling_options (PollingOptions) (defaults to: Transcripts::PollingOptions.new)

Returns:



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/assemblyai/transcripts/polling_client.rb', line 164

def wait_until_ready(transcript_id:, polling_options: Transcripts::PollingOptions.new)
  Async do
    start_time = Time.now
    timeout_in_seconds = polling_options.timeout / 1000 if polling_options.timeout.positive?
    loop do
      transcript = get(transcript_id: transcript_id)
      if transcript.status == Transcripts::TranscriptStatus::COMPLETED || transcript.status == Transcripts::TranscriptStatus::ERROR
        return transcript
      elsif polling_options.timeout.positive? && Time.now - start_time > timeout_in_seconds
        raise StandardError, "Polling timeout"
      end

      sleep polling_options.interval / 1000
    end
  end
end

#word_search(transcript_id:, words: nil, request_options: nil) ⇒ Transcripts::WordSearchResponse

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.

Parameters:

  • transcript_id (String)

    ID of the transcript

  • words (String) (defaults to: nil)

    Keywords to search for

  • request_options (RequestOptions) (defaults to: nil)

Returns:



515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/assemblyai/transcripts/client.rb', line 515

def word_search(transcript_id:, words: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
      req.params = { **(request_options&.additional_query_parameters || {}), "words": words }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript/#{transcript_id}/word-search"
    end
    Transcripts::WordSearchResponse.from_json(json_object: response.body)
  end
end