From ece2fd483a436ad325f788f8eba502fd24a295db Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 18:54:17 +0000 Subject: [PATCH 1/7] Update overview section with three main transcription callouts Co-Authored-By: Lee Vaughn --- fern/pages/01-getting-started/transcribe-an-audio-file.mdx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fern/pages/01-getting-started/transcribe-an-audio-file.mdx b/fern/pages/01-getting-started/transcribe-an-audio-file.mdx index 4c58d5ef..cbde32a4 100644 --- a/fern/pages/01-getting-started/transcribe-an-audio-file.mdx +++ b/fern/pages/01-getting-started/transcribe-an-audio-file.mdx @@ -12,6 +12,12 @@ By the end of this tutorial, you'll be able to: - Transcribe a pre-recorded audio file. - Enable [Speaker Diarization](/docs/speech-to-text/speaker-diarization) to detect speakers in an audio file. +When transcribing an audio file, there are three main things you will want to specify: + +1. Select the speech models you would like to use (required). +2. Select the region you would like to use (optional). +3. Select any other models you would like to use like Speaker Diarization or PII Redaction (optional). + Here's the full sample code for what you'll build in this tutorial: From 7f7bbc60a2e717c045cf7c134072883b3ef0fdb9 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 19:03:33 +0000 Subject: [PATCH 2/7] Fix: Update transcribe-an-audio-file2.mdx with three main transcription callouts Co-Authored-By: Lee Vaughn --- fern/pages/01-getting-started/transcribe-an-audio-file.mdx | 6 ------ fern/pages/01-getting-started/transcribe-an-audio-file2.mdx | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fern/pages/01-getting-started/transcribe-an-audio-file.mdx b/fern/pages/01-getting-started/transcribe-an-audio-file.mdx index cbde32a4..4c58d5ef 100644 --- a/fern/pages/01-getting-started/transcribe-an-audio-file.mdx +++ b/fern/pages/01-getting-started/transcribe-an-audio-file.mdx @@ -12,12 +12,6 @@ By the end of this tutorial, you'll be able to: - Transcribe a pre-recorded audio file. - Enable [Speaker Diarization](/docs/speech-to-text/speaker-diarization) to detect speakers in an audio file. -When transcribing an audio file, there are three main things you will want to specify: - -1. Select the speech models you would like to use (required). -2. Select the region you would like to use (optional). -3. Select any other models you would like to use like Speaker Diarization or PII Redaction (optional). - Here's the full sample code for what you'll build in this tutorial: diff --git a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx index d40bf40d..35bb4175 100644 --- a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx +++ b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx @@ -12,6 +12,12 @@ By the end of this tutorial, you'll be able to: - Transcribe a pre-recorded audio file. - [Select the speech model](/docs/speech-to-text/pre-recorded-audio/select-the-speech-model) for your request (optional). +When transcribing an audio file, there are three main things you will want to specify: + +1. Select the speech models you would like to use (required). +2. Select the region you would like to use (optional). +3. Select any other models you would like to use like Speaker Diarization or PII Redaction (optional). + Here's the full sample code for what you'll build in this tutorial: From 9c6ae408aa60b1fae0c4864d4bd1776694f08f72 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 19:25:42 +0000 Subject: [PATCH 3/7] Update Overview section text and code example per user request Co-Authored-By: Lee Vaughn --- .../transcribe-an-audio-file2.mdx | 163 +----------------- 1 file changed, 9 insertions(+), 154 deletions(-) diff --git a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx index 35bb4175..f89a6526 100644 --- a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx +++ b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx @@ -7,10 +7,7 @@ description: "Learn how to transcribe and analyze an audio file." ## Overview -By the end of this tutorial, you'll be able to: - -- Transcribe a pre-recorded audio file. -- [Select the speech model](/docs/speech-to-text/pre-recorded-audio/select-the-speech-model) for your request (optional). +In this tutorial, you will learn how to transcribe a pre-recorded audio file and print the transcript text to the terminal. When transcribing an audio file, there are three main things you will want to specify: @@ -20,47 +17,15 @@ When transcribing an audio file, there are three main things you will want to sp Here's the full sample code for what you'll build in this tutorial: - - - -```python -import assemblyai as aai - -aai.settings.api_key = "" - -transcriber = aai.Transcriber() - -# You can use a local filepath: -# audio_file = "./example.mp3" - -# Or use a publicly-accessible URL: -audio_file = "https://assembly.ai/sports_injuries.mp3" - -# Optionally specify a speech model (defaults to "universal"): -# config = aai.TranscriptionConfig(speech_models=["slam-1"]) -# transcript = transcriber.transcribe(audio_file, config=config) - -transcript = transcriber.transcribe(audio_file) - -if transcript.status == aai.TranscriptStatus.error: - print(f"Transcription failed: {transcript.error}") - exit(1) - -print(f" \nFull Transcript: \n\n{transcript.text}") -``` - - - - ```python import requests import time -base_url = "https://api.assemblyai.com" +base_url = "https://api.assemblyai.com" # replace with "https://api.eu.assemblyai.com" to use our EU endpoint headers = {"authorization": ""} # Use a publicly-accessible URL: -audio_file = "https://assembly.ai/sports_injuries.mp3" +audio_file = "https://assembly.ai/wildfires.mp3" ''' Or upload a local file: with open("./example.mp3", "rb") as f: @@ -76,8 +41,8 @@ with open("./example.mp3", "rb") as f: data = { "audio_url": audio_file, # For local files use: "audio_url": upload_url - # Optionally specify a speech model (defaults to "universal"): - # "speech_models": ["slam-1"] + "speech_models": ["universal-3-pro", "universal"], + "speaker_labels": True, } response = requests.post(base_url + "/v2/transcript", headers=headers, json=data) @@ -94,6 +59,10 @@ while True: transcript = requests.get(polling_endpoint, headers=headers).json() if transcript["status"] == "completed": print(f" \nFull Transcript: \n\n{transcript['text']}") + + # # comment in this section to print diarization results to the terminal + # for utterance in transcript['utterances']: + # print(f"Speaker {utterance['speaker']}: {utterance['text']}") break elif transcript["status"] == "error": raise RuntimeError(f"Transcription failed: {transcript['error']}") @@ -101,120 +70,6 @@ while True: time.sleep(3) ``` - - - -```javascript -import { AssemblyAI } from "assemblyai"; - -const client = new AssemblyAI({ - apiKey: "", -}); - -// You can use a local filepath: -// const audioFile = "./example.mp3" - -// Or use a publicly-accessible URL: -const audioFile = "https://assembly.ai/sports_injuries.mp3"; - -const params = { - audio: audioFile, - // Optionally specify a speech model (defaults to "universal"): - // speech_models: ["slam-1"], -}; - -const run = async () => { - const transcript = await client.transcripts.transcribe(params); - - if (transcript.status === "error") { - console.error(`Transcription failed: ${transcript.error}`); - process.exit(1); - } - - console.log(`\nFull Transcript:\n\n${transcript.text}\n`); -}; - -run(); -``` - - - - -```javascript -import axios from "axios"; -import fs from "fs-extra"; - -const baseUrl = "https://api.assemblyai.com"; - -const headers = { - authorization: "", -}; - -async function transcribe() { - try { - // Use a publicly accessible URL: - const audioFile = "https://assembly.ai/sports_injuries.mp3"; - - // Or upload a local file - /* - let uploadUrl - - try { - const audio = './audio/audio.mp3' - const audioData = await fs.readFile(audio) - const uploadResponse = await axios.post(`${baseUrl}/v2/upload`, audioData, { headers }) - uploadUrl = uploadResponse.data.upload_url - - } catch(error) { - console.error("Error from '/upload' request:", error.response?.data || error.response || error); - } - */ - - const data = { - audio_url: audioFile, // For local files use: audio_url: uploadUrl - // Optionally specify a speech model (defaults to "universal"): - // speech_models: ["slam-1"], - }; - - const url = `${baseUrl}/v2/transcript`; - let transcriptId; - - try { - const transcriptResponse = await axios.post(url, data, { headers }); - transcriptId = transcriptResponse.data.id; - } catch (error) { - console.error( - "Error from POST '/transcript' request:", - error.response.data.error || error - ); - } - - const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`; - - while (true) { - const pollingResponse = await axios.get(pollingEndpoint, { headers }); - const transcriptionResult = pollingResponse.data; - - if (transcriptionResult.status === "completed") { - console.log(`\nFull Transcript:\n\n${transcriptionResult.text}\n`); - break; - } else if (transcriptionResult.status === "error") { - throw new Error(`Transcription failed: ${transcriptionResult.error}`); - } else { - await new Promise((resolve) => setTimeout(resolve, 3000)); - } - } - } catch (error) { - console.error(error.message); - } -} - -transcribe(); -``` - - - - ## Before you begin To complete this tutorial, you need: From 1ee4202407af7f49f37b99d462f653a7f6eac31f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 19:30:52 +0000 Subject: [PATCH 4/7] Restore tabbed code examples with updated patterns (EU endpoint, speech_models, speaker_labels, diarization) Co-Authored-By: Lee Vaughn --- .../transcribe-an-audio-file2.mdx | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx index f89a6526..6a93b6fa 100644 --- a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx +++ b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx @@ -17,6 +17,46 @@ When transcribing an audio file, there are three main things you will want to sp Here's the full sample code for what you'll build in this tutorial: + + + +```python +import assemblyai as aai + +# Replace with "https://api.eu.assemblyai.com" to use our EU endpoint +# aai.settings.base_url = "https://api.eu.assemblyai.com" + +aai.settings.api_key = "" + +transcriber = aai.Transcriber() + +# You can use a local filepath: +# audio_file = "./example.mp3" + +# Or use a publicly-accessible URL: +audio_file = "https://assembly.ai/wildfires.mp3" + +config = aai.TranscriptionConfig( + speech_models=[aai.SpeechModel.universal_3_pro, aai.SpeechModel.universal], + speaker_labels=True, +) + +transcript = transcriber.transcribe(audio_file, config=config) + +if transcript.status == aai.TranscriptStatus.error: + print(f"Transcription failed: {transcript.error}") + exit(1) + +print(f" \nFull Transcript: \n\n{transcript.text}") + +# # comment in this section to print diarization results to the terminal +# for utterance in transcript.utterances: +# print(f"Speaker {utterance.speaker}: {utterance.text}") +``` + + + + ```python import requests import time @@ -70,6 +110,132 @@ while True: time.sleep(3) ``` + + + +```javascript +import { AssemblyAI } from "assemblyai"; + +const client = new AssemblyAI({ + apiKey: "", + // Replace with "https://api.eu.assemblyai.com" to use our EU endpoint + // baseUrl: "https://api.eu.assemblyai.com", +}); + +// You can use a local filepath: +// const audioFile = "./example.mp3" + +// Or use a publicly-accessible URL: +const audioFile = "https://assembly.ai/wildfires.mp3"; + +const params = { + audio: audioFile, + speech_models: ["universal-3-pro", "universal"], + speaker_labels: true, +}; + +const run = async () => { + const transcript = await client.transcripts.transcribe(params); + + if (transcript.status === "error") { + console.error(`Transcription failed: ${transcript.error}`); + process.exit(1); + } + + console.log(`\nFull Transcript:\n\n${transcript.text}\n`); + + // // comment in this section to print diarization results to the terminal + // for (const utterance of transcript.utterances) { + // console.log(`Speaker ${utterance.speaker}: ${utterance.text}`); + // } +}; + +run(); +``` + + + + +```javascript +import axios from "axios"; +import fs from "fs-extra"; + +const baseUrl = "https://api.assemblyai.com"; // replace with "https://api.eu.assemblyai.com" to use our EU endpoint + +const headers = { + authorization: "", +}; + +async function transcribe() { + try { + // Use a publicly accessible URL: + const audioFile = "https://assembly.ai/wildfires.mp3"; + + // Or upload a local file + /* + let uploadUrl + + try { + const audio = './audio/audio.mp3' + const audioData = await fs.readFile(audio) + const uploadResponse = await axios.post(`${baseUrl}/v2/upload`, audioData, { headers }) + uploadUrl = uploadResponse.data.upload_url + + } catch(error) { + console.error("Error from '/upload' request:", error.response?.data || error.response || error); + } + */ + + const data = { + audio_url: audioFile, // For local files use: audio_url: uploadUrl + speech_models: ["universal-3-pro", "universal"], + speaker_labels: true, + }; + + const url = `${baseUrl}/v2/transcript`; + let transcriptId; + + try { + const transcriptResponse = await axios.post(url, data, { headers }); + transcriptId = transcriptResponse.data.id; + } catch (error) { + console.error( + "Error from POST '/transcript' request:", + error.response.data.error || error + ); + } + + const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`; + + while (true) { + const pollingResponse = await axios.get(pollingEndpoint, { headers }); + const transcriptionResult = pollingResponse.data; + + if (transcriptionResult.status === "completed") { + console.log(`\nFull Transcript:\n\n${transcriptionResult.text}\n`); + + // // comment in this section to print diarization results to the terminal + // for (const utterance of transcriptionResult.utterances) { + // console.log(`Speaker ${utterance.speaker}: ${utterance.text}`); + // } + break; + } else if (transcriptionResult.status === "error") { + throw new Error(`Transcription failed: ${transcriptionResult.error}`); + } else { + await new Promise((resolve) => setTimeout(resolve, 3000)); + } + } + } catch (error) { + console.error(error.message); + } +} + +transcribe(); +``` + + + + ## Before you begin To complete this tutorial, you need: From d0084cab0df696b0574e95b6152c6615b1731466 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 19:38:23 +0000 Subject: [PATCH 5/7] Update code examples: universal-2, language_detection, broadest language coverage comment Co-Authored-By: Lee Vaughn --- .../01-getting-started/transcribe-an-audio-file2.mdx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx index 6a93b6fa..c6b6defd 100644 --- a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx +++ b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx @@ -37,7 +37,8 @@ transcriber = aai.Transcriber() audio_file = "https://assembly.ai/wildfires.mp3" config = aai.TranscriptionConfig( - speech_models=[aai.SpeechModel.universal_3_pro, aai.SpeechModel.universal], + speech_models=[aai.SpeechModel.universal_3_pro, aai.SpeechModel.universal_2], # we use both models for the broadest language coverage + language_detection=True, speaker_labels=True, ) @@ -81,7 +82,8 @@ with open("./example.mp3", "rb") as f: data = { "audio_url": audio_file, # For local files use: "audio_url": upload_url - "speech_models": ["universal-3-pro", "universal"], + "speech_models": ["universal-3-pro", "universal-2"], # we use both models for the broadest language coverage + "language_detection": True, "speaker_labels": True, } @@ -130,7 +132,8 @@ const audioFile = "https://assembly.ai/wildfires.mp3"; const params = { audio: audioFile, - speech_models: ["universal-3-pro", "universal"], + speech_models: ["universal-3-pro", "universal-2"], // we use both models for the broadest language coverage + language_detection: true, speaker_labels: true, }; @@ -188,7 +191,8 @@ async function transcribe() { const data = { audio_url: audioFile, // For local files use: audio_url: uploadUrl - speech_models: ["universal-3-pro", "universal"], + speech_models: ["universal-3-pro", "universal-2"], // we use both models for the broadest language coverage + language_detection: true, speaker_labels: true, }; From 77bdc5ffc7157badd446d2cb8d8f4f58e0d3dc06 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 20:20:44 +0000 Subject: [PATCH 6/7] Rewrite transcribe-an-audio-file page with new structure and all 4 language examples Co-Authored-By: Lee Vaughn --- .../transcribe-an-audio-file2.mdx | 995 ++++++------------ 1 file changed, 339 insertions(+), 656 deletions(-) diff --git a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx index c6b6defd..be24e60e 100644 --- a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx +++ b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx @@ -7,110 +7,88 @@ description: "Learn how to transcribe and analyze an audio file." ## Overview -In this tutorial, you will learn how to transcribe a pre-recorded audio file and print the transcript text to the terminal. +This guide walks you through transcribing your first audio file with AssemblyAI. You will learn how to submit an audio file for transcription and retrieve the results using the AssemblyAI API. When transcribing an audio file, there are three main things you will want to specify: -1. Select the speech models you would like to use (required). -2. Select the region you would like to use (optional). -3. Select any other models you would like to use like Speaker Diarization or PII Redaction (optional). +1. The speech models you would like to use (required). +2. The region you would like to use (optional). +3. Other models you would like to use like Speaker Diarization or PII Redaction (optional). -Here's the full sample code for what you'll build in this tutorial: +## Prerequisites + +Before you begin, make sure you have: -```python -import assemblyai as aai - -# Replace with "https://api.eu.assemblyai.com" to use our EU endpoint -# aai.settings.base_url = "https://api.eu.assemblyai.com" +- An AssemblyAI API key (get one by signing up at [assemblyai.com](https://assemblyai.com)) +- Python 3.8 or later installed +- The `assemblyai` package (`pip install assemblyai`) -aai.settings.api_key = "" + + -transcriber = aai.Transcriber() +- An AssemblyAI API key (get one by signing up at [assemblyai.com](https://assemblyai.com)) +- Python 3.6 or later installed +- The `requests` library (`pip install requests`) -# You can use a local filepath: -# audio_file = "./example.mp3" + + -# Or use a publicly-accessible URL: -audio_file = "https://assembly.ai/wildfires.mp3" +- An AssemblyAI API key (get one by signing up at [assemblyai.com](https://assemblyai.com)) +- Node.js 18 or later installed +- The `assemblyai` package (`npm install assemblyai`) -config = aai.TranscriptionConfig( - speech_models=[aai.SpeechModel.universal_3_pro, aai.SpeechModel.universal_2], # we use both models for the broadest language coverage - language_detection=True, - speaker_labels=True, -) + + -transcript = transcriber.transcribe(audio_file, config=config) +- An AssemblyAI API key (get one by signing up at [assemblyai.com](https://assemblyai.com)) +- Node.js 18 or later installed +- The `axios` and `fs-extra` packages (`npm install axios fs-extra`) -if transcript.status == aai.TranscriptStatus.error: - print(f"Transcription failed: {transcript.error}") - exit(1) + + -print(f" \nFull Transcript: \n\n{transcript.text}") +## Step 1: Set up your API credentials -# # comment in this section to print diarization results to the terminal -# for utterance in transcript.utterances: -# print(f"Speaker {utterance.speaker}: {utterance.text}") -``` +First, configure your API endpoint and authentication: - - + + ```python -import requests -import time - -base_url = "https://api.assemblyai.com" # replace with "https://api.eu.assemblyai.com" to use our EU endpoint -headers = {"authorization": ""} - -# Use a publicly-accessible URL: -audio_file = "https://assembly.ai/wildfires.mp3" +import assemblyai as aai -''' Or upload a local file: -with open("./example.mp3", "rb") as f: - response = requests.post(base_url + "/v2/upload", headers=headers, data=f) +aai.settings.api_key = "YOUR_API_KEY" +``` - if response.status_code != 200: - print(f"Error: {response.status_code}, Response: {response.text}") - response.raise_for_status() +Replace `YOUR_API_KEY` with your actual AssemblyAI API key. - upload_json = response.json() - upload_url = upload_json["upload_url"] -''' + +If you are using the EU endpoint, add this line before setting your API key: -data = { - "audio_url": audio_file, # For local files use: "audio_url": upload_url - "speech_models": ["universal-3-pro", "universal-2"], # we use both models for the broadest language coverage - "language_detection": True, - "speaker_labels": True, -} +```python +aai.settings.base_url = "https://api.eu.assemblyai.com" +``` + -response = requests.post(base_url + "/v2/transcript", headers=headers, json=data) + + -if response.status_code != 200: - print(f"Error: {response.status_code}, Response: {response.text}") - response.raise_for_status() +```python +import requests +import time -transcript_json = response.json() -transcript_id = transcript_json["id"] -polling_endpoint = f"{base_url}/v2/transcript/{transcript_id}" +base_url = "https://api.assemblyai.com" +headers = {"authorization": "YOUR_API_KEY"} +``` -while True: - transcript = requests.get(polling_endpoint, headers=headers).json() - if transcript["status"] == "completed": - print(f" \nFull Transcript: \n\n{transcript['text']}") +Replace `YOUR_API_KEY` with your actual AssemblyAI API key. - # # comment in this section to print diarization results to the terminal - # for utterance in transcript['utterances']: - # print(f"Speaker {utterance['speaker']}: {utterance['text']}") - break - elif transcript["status"] == "error": - raise RuntimeError(f"Transcription failed: {transcript['error']}") - else: - time.sleep(3) -``` + +If you are using the EU endpoint, change the base URL to `https://api.eu.assemblyai.com`. + @@ -119,42 +97,22 @@ while True: import { AssemblyAI } from "assemblyai"; const client = new AssemblyAI({ - apiKey: "", - // Replace with "https://api.eu.assemblyai.com" to use our EU endpoint - // baseUrl: "https://api.eu.assemblyai.com", + apiKey: "YOUR_API_KEY", }); +``` -// You can use a local filepath: -// const audioFile = "./example.mp3" - -// Or use a publicly-accessible URL: -const audioFile = "https://assembly.ai/wildfires.mp3"; - -const params = { - audio: audioFile, - speech_models: ["universal-3-pro", "universal-2"], // we use both models for the broadest language coverage - language_detection: true, - speaker_labels: true, -}; - -const run = async () => { - const transcript = await client.transcripts.transcribe(params); - - if (transcript.status === "error") { - console.error(`Transcription failed: ${transcript.error}`); - process.exit(1); - } - - console.log(`\nFull Transcript:\n\n${transcript.text}\n`); +Replace `YOUR_API_KEY` with your actual AssemblyAI API key. - // // comment in this section to print diarization results to the terminal - // for (const utterance of transcript.utterances) { - // console.log(`Speaker ${utterance.speaker}: ${utterance.text}`); - // } -}; + +If you are using the EU endpoint, add the `baseUrl` option: -run(); +```javascript +const client = new AssemblyAI({ + apiKey: "YOUR_API_KEY", + baseUrl: "https://api.eu.assemblyai.com", +}); ``` + @@ -163,633 +121,370 @@ run(); import axios from "axios"; import fs from "fs-extra"; -const baseUrl = "https://api.assemblyai.com"; // replace with "https://api.eu.assemblyai.com" to use our EU endpoint +const baseUrl = "https://api.assemblyai.com"; const headers = { - authorization: "", + authorization: "YOUR_API_KEY", }; +``` -async function transcribe() { - try { - // Use a publicly accessible URL: - const audioFile = "https://assembly.ai/wildfires.mp3"; - - // Or upload a local file - /* - let uploadUrl - - try { - const audio = './audio/audio.mp3' - const audioData = await fs.readFile(audio) - const uploadResponse = await axios.post(`${baseUrl}/v2/upload`, audioData, { headers }) - uploadUrl = uploadResponse.data.upload_url - - } catch(error) { - console.error("Error from '/upload' request:", error.response?.data || error.response || error); - } - */ - - const data = { - audio_url: audioFile, // For local files use: audio_url: uploadUrl - speech_models: ["universal-3-pro", "universal-2"], // we use both models for the broadest language coverage - language_detection: true, - speaker_labels: true, - }; - - const url = `${baseUrl}/v2/transcript`; - let transcriptId; - - try { - const transcriptResponse = await axios.post(url, data, { headers }); - transcriptId = transcriptResponse.data.id; - } catch (error) { - console.error( - "Error from POST '/transcript' request:", - error.response.data.error || error - ); - } +Replace `YOUR_API_KEY` with your actual AssemblyAI API key. - const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`; - - while (true) { - const pollingResponse = await axios.get(pollingEndpoint, { headers }); - const transcriptionResult = pollingResponse.data; - - if (transcriptionResult.status === "completed") { - console.log(`\nFull Transcript:\n\n${transcriptionResult.text}\n`); - - // // comment in this section to print diarization results to the terminal - // for (const utterance of transcriptionResult.utterances) { - // console.log(`Speaker ${utterance.speaker}: ${utterance.text}`); - // } - break; - } else if (transcriptionResult.status === "error") { - throw new Error(`Transcription failed: ${transcriptionResult.error}`); - } else { - await new Promise((resolve) => setTimeout(resolve, 3000)); - } - } - } catch (error) { - console.error(error.message); - } -} - -transcribe(); -``` + +If you are using the EU endpoint, change the base URL to `https://api.eu.assemblyai.com`. + -## Before you begin +## Step 2: Specify your audio source -To complete this tutorial, you need: +You can transcribe audio files in two ways: -- If opting to use the Python or Python SDK code, you will need [Python](https://www.python.org/) installed. -- If opting to use the JavaScript or JavaScript SDK code, you will need [Node.js](https://nodejs.org/) installed. -- - A free AssemblyAI account. - - -## Step 1: Install the necessary libraries - - - - - - + + -Install our Python SDK via pip: +**Option A: Use a publicly accessible URL** -```bash -pip install assemblyai +```python +audio_file = "https://assembly.ai/wildfires.mp3" ``` - - - -Create a new file and import the `assemblyai` package. +**Option B: Use a local file** ```python -import assemblyai as aai +audio_file = "./example.mp3" ``` - - +The SDK handles local file uploads automatically. - - - -Install the requests library used for making an HTTP request. +**Option A: Use a publicly accessible URL** -```bash -pip install requests +```python +audio_file = "https://assembly.ai/wildfires.mp3" ``` - - +**Option B: Upload a local file** -Create a new file and import the requests and time library. +If your audio file is stored locally, upload it to AssemblyAI first: ```python -import requests -import time +with open("./example.mp3", "rb") as f: + response = requests.post(base_url + "/v2/upload", headers=headers, data=f) + + if response.status_code != 200: + print(f"Error: {response.status_code}, Response: {response.text}") + response.raise_for_status() + + upload_json = response.json() + audio_file = upload_json["upload_url"] ``` - - - - -Install the `assemblyai` package via NPM: +**Option A: Use a publicly accessible URL** -```bash -npm install assemblyai +```javascript +const audioFile = "https://assembly.ai/wildfires.mp3"; ``` - - - -Create a new file and import the `assemblyai` package. +**Option B: Use a local file** ```javascript -import { AssemblyAI } from "assemblyai"; +const audioFile = "./example.mp3"; ``` - - +The SDK handles local file uploads automatically. - - - -Install the `axios` and `fs-extra` packages via NPM: +**Option A: Use a publicly accessible URL** -```bash -npm install axios fs-extra +```javascript +const audioFile = "https://assembly.ai/wildfires.mp3"; ``` - - +**Option B: Upload a local file** -Create a new file and import the `axios` and `fs-extra` packages. +If your audio file is stored locally, upload it to AssemblyAI first: ```javascript -import axios from "axios"; -import fs from "fs-extra"; +const audioData = await fs.readFile("./example.mp3"); +const uploadResponse = await axios.post(`${baseUrl}/v2/upload`, audioData, { headers }); +const audioFile = uploadResponse.data.upload_url; ``` - - -## Step 2: Configure your request - - - -In this step, you'll create an SDK client and configure it to use your API key. - - - - -Browse to API Keys in your dashboard, and then copy your API key. - - +## Step 3: Submit the transcription request - +Create a request with your audio URL and desired configuration options: -Create a new `Transcriber` and configure it to use your API key. Replace `YOUR_API_KEY` with your copied API key. - -```python -aai.settings.api_key = "" - -transcriber = aai.Transcriber() -``` - - - - -Specify a URL to the audio you want to transcribe. The URL needs to be accessible from AssemblyAI's servers. For a list of supported formats, see [FAQ](/docs/faq/what-audio-and-video-file-types-are-supported-by-your-api). + + ```python -audio_file = "https://assembly.ai/sports_injuries.mp3" -``` - - - -You can use a service like Amazon S3, Google Cloud Storage, or any platform that supports direct file access to generate a shareable audio file URL. Check out this cookbook on how to [transcribe from an S3 bucket.](/docs/guides/transcribe_from_s3) - - - - - -If you want to use a local file, you can also specify a local path, for example: +config = aai.TranscriptionConfig( + speech_models=[aai.SpeechModel.universal_3_pro, aai.SpeechModel.universal_2], + language_detection=True, + speaker_labels=True, +) -```python -audio_file = "./example.mp3" +transcript = aai.Transcriber().transcribe(audio_file, config=config) ``` - - - - -YouTube URLs are not supported. If you want to transcribe a YouTube video, you need to download the audio first. - - - - - - -In this step you'll set the base URL and configure your API key. - - - - -Browse to API Keys in your dashboard, and then copy your API key. - - - - -Set the base URL and set your headers. Replace `YOUR_API_KEY` with your copied API key. - -```python -base_url = "https://api.assemblyai.com" - -headers = { "authorization": ""} -``` - - - - -Specify a URL to the audio you want to transcribe. The URL needs to be accessible from AssemblyAI's servers. For a list of supported formats, see [FAQ](/docs/faq/what-audio-and-video-file-types-are-supported-by-your-api). - ```python -audio_file = "https://assembly.ai/sports_injuries.mp3" -``` - - - -You can use a service like Amazon S3, Google Cloud Storage, or any platform that supports direct file access to generate a shareable audio file URL. Check out this cookbook on how to [transcribe from an S3 bucket.](/docs/guides/transcribe_from_s3) - - - - +data = { + "audio_url": audio_file, + "speech_models": ["universal-3-pro", "universal-2"], + "language_detection": True, + "speaker_labels": True +} -If you want to use a local file, you can send the file to our upload endpoint. You'll want to add some error handling in case the upload fails. If the request is successful, the upload endpoint will respond with an `upload_url` : +response = requests.post(base_url + "/v2/transcript", headers=headers, json=data) -```python -with open("./example.mp3", "rb") as f: - response = requests.post(base_url + "/v2/upload", headers=headers, data=f) if response.status_code != 200: print(f"Error: {response.status_code}, Response: {response.text}") response.raise_for_status() -upload_json = response.json() -upload_url = upload_json["upload_url"] -``` - -We delete uploaded files from our servers either after the transcription has completed, or 24 hours after you uploaded the file. After the file has been deleted, the corresponding `upload_url` is no longer valid. - - - - - -YouTube URLs are not supported. If you want to transcribe a YouTube video, you need to download the audio first. - - - - - -Pass the audio URL to the data object. - -```python -data = {"audio_url": audio_file} -# Or pass the upload_url if you used the upload endpoint -# data = {"audio_url": upload_url} +transcript_json = response.json() +transcript_id = transcript_json["id"] ``` - - - -In this step, you'll create an SDK client and configure it to use your API key. - - - - -Browse to API Keys in your dashboard, and then copy your API key. - - - - - -Create a new client using your API key. Replace `YOUR_API_KEY` with your copied API key. - ```javascript -import { AssemblyAI } from "assemblyai"; +const params = { + audio: audioFile, + speech_models: ["universal-3-pro", "universal-2"], + language_detection: true, + speaker_labels: true, +}; -const client = new AssemblyAI({ - apiKey: "", -}); +const transcript = await client.transcripts.transcribe(params); ``` - - - -Specify a URL to the audio you want to transcribe. The URL needs to be accessible from AssemblyAI's servers. For a list of supported formats, see [FAQ](/docs/faq/what-audio-and-video-file-types-are-supported-by-your-api). + + ```javascript -const audioFile = "https://assembly.ai/sports_injuries.mp3"; -``` - - - You can use a service like Amazon S3, Google Cloud Storage, or any platform - that supports direct file access to generate a shareable audio file URL. Check - out this cookbook on how to [transcribe from an S3 - bucket.](/docs/guides/transcribe_from_s3) - - - - -If you want to use a local file, you can also specify a local path, for example: +const data = { + audio_url: audioFile, + speech_models: ["universal-3-pro", "universal-2"], + language_detection: true, + speaker_labels: true, +}; -```javascript -const audioFile = "./example.mp3"; +const transcriptResponse = await axios.post(`${baseUrl}/v2/transcript`, data, { headers }); +const transcriptId = transcriptResponse.data.id; ``` - + + - +This configuration: -YouTube URLs are not supported. If you want to transcribe a YouTube video, you need to download the audio first. +- Uses both the `universal-3-pro` and `universal-2` models for broad language coverage +- Automatically detects the spoken language +- Identifies different speakers in the audio - +## Step 4: Poll for the transcription result - - +Transcription happens asynchronously. Poll the API until the transcription is complete: - - -In this step you'll set the base URL and configure your API key. - - + + -Browse to API Keys in your dashboard, and then copy your API key. +The SDK handles polling automatically. Check the result: - +```python +if transcript.status == aai.TranscriptStatus.error: + raise RuntimeError(f"Transcription failed: {transcript.error}") - +print(f"\nFull Transcript:\n\n{transcript.text}") +``` -Set the base URL and set your headers. Replace `YOUR_API_KEY` with your copied API key. + + -```javascript -const baseUrl = "https://api.assemblyai.com"; +```python +polling_endpoint = f"{base_url}/v2/transcript/{transcript_id}" -const headers = { - authorization: "", -}; +while True: + transcript = requests.get(polling_endpoint, headers=headers).json() + + if transcript["status"] == "completed": + print(f"\nFull Transcript:\n\n{transcript['text']}") + break + elif transcript["status"] == "error": + raise RuntimeError(f"Transcription failed: {transcript['error']}") + else: + time.sleep(3) ``` - - +The polling loop checks the transcription status every 3 seconds and prints the full transcript once processing is complete. -Create a `transcribe` function and specify a URL to the audio you want to transcribe. Add a `data` object and pass the `audioFile` to the `audio_url` parameter. The URL needs to be accessible from AssemblyAI's servers. For a list of supported formats, see [FAQ](https://support.assemblyai.com/). + + + +The SDK handles polling automatically. Check the result: ```javascript -async function transcribe() { - const audioFile = "https://assembly.ai/sports_injuries.mp3"; - const data = { audio_url: audioFile }; +if (transcript.status === "error") { + throw new Error(`Transcription failed: ${transcript.error}`); } -``` - - -You can use a service like Amazon S3, Google Cloud Storage, or any platform that supports direct file access to generate a shareable audio file URL. Check out this cookbook on how to [transcribe from an S3 bucket.](/docs/guides/transcribe_from_s3) +console.log(`\nFull Transcript:\n\n${transcript.text}`); +``` - + + - +```javascript +const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`; -If you want to use a local file, you can send the file to our upload endpoint. You'll want to add some error handling in case the upload fails. If the request is successful, the upload endpoint will respond with an upload URL : +while (true) { + const pollingResponse = await axios.get(pollingEndpoint, { headers }); + const transcript = pollingResponse.data; -```javascript -async function transcribe() { - let uploadUrl; - - try { - const audio = "./example.mp3"; - const audioData = await fs.readFile(audio); - const uploadResponse = await axios.post(`${baseUrl}/v2/upload`, audioData, { - headers, - }); - uploadUrl = uploadResponse.data.upload_url; - } catch (error) { - console.error( - "Error from '/upload' request:", - error.response?.data || error.response || error - ); + if (transcript.status === "completed") { + console.log(`\nFull Transcript:\n\n${transcript.text}`); + break; + } else if (transcript.status === "error") { + throw new Error(`Transcription failed: ${transcript.error}`); + } else { + await new Promise((resolve) => setTimeout(resolve, 3000)); } - - const data = { audio_url: uploadUrl }; } ``` -We delete uploaded files from our servers either after the transcription has completed, or 24 hours after you uploaded the file. After the file has been deleted, the corresponding `upload_url` is no longer valid. - - - - - -YouTube URLs are not supported. If you want to transcribe a YouTube video, you need to download the audio first. - - - - +The polling loop checks the transcription status every 3 seconds and prints the full transcript once processing is complete. -## Step 3: Select the speech model (optional) - -AssemblyAI offers multiple speech models optimized for different use cases. You can use the `speech_models` parameter to specify which model to use for your transcription. - -The available models are: - -- **Universal** (default): Best for out-of-the-box transcription with multi-language support and excellent accuracy. -- **Slam-1** (beta): Highest accuracy for English content with fine-tuning support and customization via prompting. - -For more details on model capabilities and pricing, see [Models](/docs/getting-started/models). - - - If you do not specify a speech model, the Universal model will be used by - default. - - - - +## Step 5: Access speaker diarization (optional) -To specify a speech model, create a `TranscriptionConfig` with the `speech_models` parameter: +If you enabled speaker labels, you can access the speaker-separated utterances: -```python -config = aai.TranscriptionConfig(speech_models=["slam-1"]) -``` - -You can also specify multiple models in priority order. The system will use the first compatible model: + + ```python -config = aai.TranscriptionConfig(speech_models=["slam-1", "universal"]) +for utterance in transcript.utterances: + print(f"Speaker {utterance.speaker}: {utterance.text}") ``` -To specify a speech model, add the `speech_models` parameter to the data object: - ```python -data = { - "audio_url": audio_file, - "speech_models": ["slam-1"] -} -``` - -You can also specify multiple models in priority order. The system will use the first compatible model: - -```python -data = { - "audio_url": audio_file, - "speech_models": ["slam-1", "universal"] -} +for utterance in transcript['utterances']: + print(f"Speaker {utterance['speaker']}: {utterance['text']}") ``` -To specify a speech model, set the `speech_models` property in the params object: - ```javascript -const params = { - audio: audioFile, - speech_models: ["slam-1"], -}; -``` - -You can also specify multiple models in priority order. The system will use the first compatible model: - -```javascript -const params = { - audio: audioFile, - speech_models: ["slam-1", "universal"], -}; +for (const utterance of transcript.utterances) { + console.log(`Speaker ${utterance.speaker}: ${utterance.text}`); +} ``` -To specify a speech model, add the `speech_models` property to the data object: - -```javascript -const data = { - audio_url: audioFile, - speech_models: ["slam-1"], -}; -``` - -You can also specify multiple models in priority order. The system will use the first compatible model: - ```javascript -const data = { - audio_url: audioFile, - speech_models: ["slam-1", "universal"], -}; +for (const utterance of transcript.utterances) { + console.log(`Speaker ${utterance.speaker}: ${utterance.text}`); +} ``` -For more information on selecting speech models, see [Select the speech model](/docs/speech-to-text/pre-recorded-audio/select-the-speech-model). - -## Step 4: Submit for transcription +## Complete example - - - - +Here is the full working code: -To generate the transcript, pass the `audio_file` or file to `transcriber.transcribe()`. This may take a minute while we're processing the audio. + + ```python -transcript = transcriber.transcribe(audio_file) -``` +import assemblyai as aai -If you configured a `TranscriptionConfig` in Step 3, pass it to the `transcribe()` method: +aai.settings.api_key = "YOUR_API_KEY" -```python -transcript = transcriber.transcribe(audio_file, config=config) -``` +# Use a publicly-accessible URL +audio_file = "https://assembly.ai/wildfires.mp3" - - +# Or use a local file: +# audio_file = "./example.mp3" -If the transcription failed, the `status` of the transcription will be set to -`error`. To see why it failed you can print the value of `error`. +config = aai.TranscriptionConfig( + speech_models=[aai.SpeechModel.universal_3_pro, aai.SpeechModel.universal_2], + language_detection=True, + speaker_labels=True, +) -```python -if transcript.error: - print(transcript.error) - exit(1) -``` +transcript = aai.Transcriber().transcribe(audio_file, config=config) - - +if transcript.status == aai.TranscriptStatus.error: + raise RuntimeError(f"Transcription failed: {transcript.error}") -Print the complete transcript. +print(f"\nFull Transcript:\n\n{transcript.text}") -```python -print(transcript.text) +# Optionally print speaker diarization results +# for utterance in transcript.utterances: +# print(f"Speaker {utterance.speaker}: {utterance.text}") ``` - - + + -Run the application and wait for it to finish. +```python +import requests +import time - - +base_url = "https://api.assemblyai.com" +headers = {"authorization": "YOUR_API_KEY"} - - +# Use a publicly-accessible URL +audio_file = "https://assembly.ai/wildfires.mp3" - - +# Or upload a local file: +# with open("./example.mp3", "rb") as f: +# response = requests.post(base_url + "/v2/upload", headers=headers, data=f) +# if response.status_code != 200: +# print(f"Error: {response.status_code}, Response: {response.text}") +# response.raise_for_status() +# upload_json = response.json() +# audio_file = upload_json["upload_url"] -Make a `POST` request to the AssemblyAI API endpoint with the payload and headers and check for potential errors. +data = { + "audio_url": audio_file, + "speech_models": ["universal-3-pro", "universal-2"], + "language_detection": True, + "speaker_labels": True +} -```python response = requests.post(base_url + "/v2/transcript", headers=headers, json=data) if response.status_code != 200: print(f"Error: {response.status_code}, Response: {response.text}") response.raise_for_status() -``` - - - - -After making the request, you’ll receive an `id` for the transcription. Use it to poll the API every few seconds to check the `status` of the transcript job. Once the `status` is `completed`, you can retrieve the transcript from the API response. If the `status` is `error`, print the error value to get more information on why your request failed. -```python transcript_json = response.json() transcript_id = transcript_json["id"] polling_endpoint = f"{base_url}/v2/transcript/{transcript_id}" @@ -797,7 +492,11 @@ polling_endpoint = f"{base_url}/v2/transcript/{transcript_id}" while True: transcript = requests.get(polling_endpoint, headers=headers).json() if transcript["status"] == "completed": - print(transcript["text"]) + print(f"\nFull Transcript:\n\n{transcript['text']}") + + # Optionally print speaker diarization results + # for utterance in transcript['utterances']: + # print(f"Speaker {utterance['speaker']}: {utterance['text']}") break elif transcript["status"] == "error": raise RuntimeError(f"Transcription failed: {transcript['error']}") @@ -805,129 +504,113 @@ while True: time.sleep(3) ``` - - - -Run the application and wait for it to finish. - - - - - - - -To generate the transcript, pass the audio URL to `client.transcripts.transcribe()`. This may take a minute while we're processing the audio. ```javascript -const transcript = await client.transcripts.transcribe(params); -``` +import { AssemblyAI } from "assemblyai"; - - +const client = new AssemblyAI({ + apiKey: "YOUR_API_KEY", +}); -If the transcription failed, the `status` of the transcription will be set to -`error`. To see why it failed you can print the value of `error`. +// Use a publicly-accessible URL +const audioFile = "https://assembly.ai/wildfires.mp3"; -```javascript -if (transcript.status === "error") { - console.error(transcript.error); - process.exit(1); -} -``` +// Or use a local file: +// const audioFile = "./example.mp3"; - - +const params = { + audio: audioFile, + speech_models: ["universal-3-pro", "universal-2"], + language_detection: true, + speaker_labels: true, +}; -Print the complete transcript. +const run = async () => { + const transcript = await client.transcripts.transcribe(params); -```javascript -console.log(transcript.text); -``` + if (transcript.status === "error") { + throw new Error(`Transcription failed: ${transcript.error}`); + } - - + console.log(`\nFull Transcript:\n\n${transcript.text}`); -Run the application and wait for it to finish. + // Optionally print speaker diarization results + // for (const utterance of transcript.utterances) { + // console.log(`Speaker ${utterance.speaker}: ${utterance.text}`); + // } +}; - - +run(); +``` - - - -Under the `data` object, make a `POST` request to the AssemblyAI API endpoint with the payload and headers and check for potential errors. After making the request, you’ll receive an `id` for the transcription. Store it to use in the next step. ```javascript -try { - const url = `${baseUrl}/v2/transcript`; - let transcriptId; - try { - const transcriptResponse = await axios.post(url, data, { headers }); - transcriptId = transcriptResponse.data.id; - } catch (error) { - console.error( - "Error from POST '/transcript' request:", - error.response.data.error || error - ); - } - - //Polling code for next step will be here -} catch (error) { - console.error(error.message); -} -``` - - - - -After the `POST` request, use the `id` to poll the API every few seconds to check the `status` of the transcript job. Once the `status` is `completed`, you can retrieve the transcript from the API response. If the `status` is `error`, print the error value to get more information on why your request failed. - -```javascript -const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`; +import axios from "axios"; +import fs from "fs-extra"; -while (true) { - const pollingResponse = await axios.get(pollingEndpoint, { headers }); +const baseUrl = "https://api.assemblyai.com"; - const transcriptionResult = pollingResponse.data; +const headers = { + authorization: "YOUR_API_KEY", +}; - if (transcriptionResult.status === "completed") { - console.log(transcriptionResult.text); - break; - } else if (transcriptionResult.status === "error") { - throw new Error(`Transcription failed: ${transcriptionResult.error}`); - } else { - await new Promise((resolve) => setTimeout(resolve, 3000)); +async function transcribe() { + // Use a publicly-accessible URL + const audioFile = "https://assembly.ai/wildfires.mp3"; + + // Or upload a local file: + // const audioData = await fs.readFile("./example.mp3"); + // const uploadResponse = await axios.post(`${baseUrl}/v2/upload`, audioData, { headers }); + // const audioFile = uploadResponse.data.upload_url; + + const data = { + audio_url: audioFile, + speech_models: ["universal-3-pro", "universal-2"], + language_detection: true, + speaker_labels: true, + }; + + const transcriptResponse = await axios.post(`${baseUrl}/v2/transcript`, data, { headers }); + const transcriptId = transcriptResponse.data.id; + const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`; + + while (true) { + const pollingResponse = await axios.get(pollingEndpoint, { headers }); + const transcript = pollingResponse.data; + + if (transcript.status === "completed") { + console.log(`\nFull Transcript:\n\n${transcript.text}`); + + // Optionally print speaker diarization results + // for (const utterance of transcript.utterances) { + // console.log(`Speaker ${utterance.speaker}: ${utterance.text}`); + // } + break; + } else if (transcript.status === "error") { + throw new Error(`Transcription failed: ${transcript.error}`); + } else { + await new Promise((resolve) => setTimeout(resolve, 3000)); + } } } -``` - - - - -Call the `transcribe` function, run the application and wait for it to finish. -```javascript transcribe(); ``` - - - ## Next steps -Want to learn more? - -- For more ways to analyze your audio data, explore our [Speech Understanding features](https://www.assemblyai.com/products/speech-understanding). -- To search, summarize, and ask questions on your transcripts with LLMs, see [LLM Gateway](/docs/llm-gateway/overview). -- For detailed endpoint documentation, see the [API Reference](/docs/api-reference/overview). +Now that you have transcribed your first audio file: -## Need some help? +- Learn how you can do even more with Universal-3-Pro with [natural language prompting](/docs/getting-started/universal-3-pro#natural-language-prompting) +- Explore [our Speech Understanding features](https://www.assemblyai.com/products/speech-understanding) for more ways to analyze your audio data +- Learn more about searching, summarizing, or asking questions on your transcript with [our LLM Gateway feature](/docs/llm-gateway/overview) +- Find out how to use [webhooks](/docs/deployment/webhooks) to get notified when your transcripts are ready -If you get stuck, or have any other questions, we'd love to help you out. Contact our support team at support@assemblyai.com or create a [support ticket](https://www.assemblyai.com/contact/support). +For more information, check out the full [API reference documentation](https://www.assemblyai.com/docs). From 05992c48c4aed4a070e1d5f998ca503395e79cc0 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 20:47:13 +0000 Subject: [PATCH 7/7] Add refinements: Info callouts for EU endpoint, base_url to SDK examples, pricing warning, and documentation links Co-Authored-By: Lee Vaughn --- .../transcribe-an-audio-file2.mdx | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx index be24e60e..a80a5be0 100644 --- a/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx +++ b/fern/pages/01-getting-started/transcribe-an-audio-file2.mdx @@ -60,18 +60,15 @@ First, configure your API endpoint and authentication: ```python import assemblyai as aai +aai.settings.base_url = "https://api.assemblyai.com" aai.settings.api_key = "YOUR_API_KEY" ``` Replace `YOUR_API_KEY` with your actual AssemblyAI API key. - -If you are using the EU endpoint, add this line before setting your API key: - -```python -aai.settings.base_url = "https://api.eu.assemblyai.com" -``` - + +Use our EU endpoint by changing `base_url` to `"https://api.eu.assemblyai.com"`. + @@ -86,9 +83,9 @@ headers = {"authorization": "YOUR_API_KEY"} Replace `YOUR_API_KEY` with your actual AssemblyAI API key. - -If you are using the EU endpoint, change the base URL to `https://api.eu.assemblyai.com`. - + +Use our EU endpoint by changing `base_url` to `"https://api.eu.assemblyai.com"`. + @@ -96,23 +93,19 @@ If you are using the EU endpoint, change the base URL to `https://api.eu.assembl ```javascript import { AssemblyAI } from "assemblyai"; +const baseUrl = "https://api.assemblyai.com"; + const client = new AssemblyAI({ apiKey: "YOUR_API_KEY", + baseUrl: baseUrl, }); ``` Replace `YOUR_API_KEY` with your actual AssemblyAI API key. - -If you are using the EU endpoint, add the `baseUrl` option: - -```javascript -const client = new AssemblyAI({ - apiKey: "YOUR_API_KEY", - baseUrl: "https://api.eu.assemblyai.com", -}); -``` - + +Use our EU endpoint by changing `baseUrl` to `"https://api.eu.assemblyai.com"`. + @@ -130,9 +123,9 @@ const headers = { Replace `YOUR_API_KEY` with your actual AssemblyAI API key. - -If you are using the EU endpoint, change the base URL to `https://api.eu.assemblyai.com`. - + +Use our EU endpoint by changing `baseUrl` to `"https://api.eu.assemblyai.com"`. + @@ -294,9 +287,15 @@ const transcriptId = transcriptResponse.data.id; This configuration: -- Uses both the `universal-3-pro` and `universal-2` models for broad language coverage -- Automatically detects the spoken language -- Identifies different speakers in the audio +- Uses both the `universal-3-pro` and `universal-2` models for broad language coverage. Learn more about our different speech recognition models [here](/docs/getting-started/models). +- Uses [our Automatic Language Detection model](/docs/pre-recorded-audio/automatic-language-detection) to detect the dominant language in the spoken audio. +- Uses [our Speaker Diarization model](/docs/pre-recorded-audio/speaker-diarization) to create turn-by-turn utterances. + + +Pricing can vary based on the speech model used in the request. + +If you already have an account with us, you can find your specific pricing on [the Billing page](https://www.assemblyai.com/dashboard/account/billing) of your dashboard. If you are a new customer, you can find general pricing information [here](https://www.assemblyai.com/pricing). + ## Step 4: Poll for the transcription result @@ -424,6 +423,7 @@ Here is the full working code: ```python import assemblyai as aai +aai.settings.base_url = "https://api.assemblyai.com" aai.settings.api_key = "YOUR_API_KEY" # Use a publicly-accessible URL @@ -510,8 +510,11 @@ while True: ```javascript import { AssemblyAI } from "assemblyai"; +const baseUrl = "https://api.assemblyai.com"; + const client = new AssemblyAI({ apiKey: "YOUR_API_KEY", + baseUrl: baseUrl, }); // Use a publicly-accessible URL