Method: AssemblyAI::TranscriptsClient#submit

Defined in:
lib/assemblyai/transcripts/client.rb

#submit(audio_url:, language_code: nil, language_detection: nil, language_confidence_threshold: nil, speech_model: nil, punctuate: nil, format_text: nil, disfluencies: nil, multichannel: 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, custom_spelling: 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, request_options: nil) ⇒ AssemblyAI::Transcripts::Transcript

Create a transcript from a media file that is accessible via a URL.

Examples:

api = AssemblyAI::Client.new(
  environment: AssemblyAI::Environment::DEFAULT,
  base_url: "https://api.example.com",
  api_key: "YOUR_API_KEY"
)
api.transcripts.submit(audio_url: "https://assembly.ai/wildfires.mp3")

Parameters:

  • language_code (AssemblyAI::Transcripts::TranscriptLanguageCode) (defaults to: nil)
  • language_detection (Boolean) (defaults to: nil)

    Enable [Automatic language www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection), either true or false.

  • language_confidence_threshold (Float) (defaults to: nil)

    The confidence threshold for the automatically detected language. An error will be returned if the language confidence is below this threshold. Defaults to 0.

  • speech_model (AssemblyAI::Transcripts::SpeechModel) (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

  • disfluencies (Boolean) (defaults to: nil)

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

  • multichannel (Boolean) (defaults to: nil)
  • dual_channel (Boolean) (defaults to: nil)

    Enable [Dual ://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 we send webhook requests. We sends two different types of webhook requests. One request when a transcript is completed or failed, and one request when the redacted audio is ready if redact_pii_audio is enabled.

  • webhook_auth_header_name (String) (defaults to: nil)

    The header name to be sent with the transcript completed or failed webhook requests

  • webhook_auth_header_value (String) (defaults to: nil)

    The header value to send back with the transcript completed or failed webhook requests for added security

  • auto_highlights (Boolean) (defaults to: nil)

    Enable Key Phrases, 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 (AssemblyAI::Transcripts::TranscriptBoostParam) (defaults to: nil)

    How much to boost specified words

  • 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 (AssemblyAI::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<AssemblyAI::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 (AssemblyAI::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 the Content Moderation model. 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

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

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

    • :from (Array<String>)

    • :to (String)

  • 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 (AssemblyAI::Transcripts::SummaryModel) (defaults to: nil)

    The model to summarize the transcript

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

    The type of summary

  • custom_topics (Boolean) (defaults to: nil)

    Enable custom topics, either true or false

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

    The list of custom topics

  • audio_url (String)

    The URL of the audio or video file to transcribe.

  • request_options (AssemblyAI::RequestOptions) (defaults to: nil)

Returns:



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/assemblyai/transcripts/client.rb', line 164

def submit(audio_url:, language_code: nil, language_detection: nil, language_confidence_threshold: nil, speech_model: nil,
           punctuate: nil, format_text: nil, disfluencies: nil, multichannel: 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, custom_spelling: 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, request_options: nil)
  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 || {}),
      language_code: language_code,
      language_detection: language_detection,
      language_confidence_threshold: language_confidence_threshold,
      speech_model: speech_model,
      punctuate: punctuate,
      format_text: format_text,
      disfluencies: disfluencies,
      multichannel: multichannel,
      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,
      custom_spelling: custom_spelling,
      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,
      audio_url: audio_url
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/v2/transcript"
  end
  AssemblyAI::Transcripts::Transcript.from_json(json_object: response.body)
end