From b2fbabfd68d08747d938bc864f5f8e7d1347f839 Mon Sep 17 00:00:00 2001 From: Zineb Date: Thu, 5 Mar 2026 18:58:24 +0000 Subject: [PATCH] Update README to showcase speech model selection Updated the first code snippets for async and streaming to explicitly show model parameters, matching our current documentation. This could help prevent tools like Claude Code from defaulting to Nano when scaffolding projects from the SDK README. Changes: Setup: Added baseUrl to client constructor Async: Updated first transcribe example to use speech_models: ["universal-3-pro", "universal-2"] with language_detection Streaming: Collapsed two constructor blocks into one with speechModel: "u3-rt-pro", sampleRate, and formatTurns Updated audio URL from espn.m4a to sports_injuries.mp3 to match current docs --- README.md | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d21a351..d586ed7 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,11 @@ Then, import the `assemblyai` module and create an AssemblyAI object with your A ```js import { AssemblyAI } from "assemblyai"; +const baseUrl = "https://api.assemblyai.com"; + const client = new AssemblyAI({ - apiKey: process.env.ASSEMBLYAI_API_KEY, + apiKey: "YOUR_API_KEY", + baseUrl: baseUrl, }); ``` @@ -96,9 +99,20 @@ When you create a transcript, you can either pass in a URL to an audio file or u ```js // Transcribe file at remote URL -let transcript = await client.transcripts.transcribe({ - audio: "https://assembly.ai/espn.m4a", -}); +const audioFile = "https://assembly.ai/sports_injuries.mp3"; + +const params = { + audio: audioFile, + speech_models: ["universal-3-pro", "universal-2"], + language_detection: true, +}; + +const run = async () => { + const transcript = await client.transcripts.transcribe(params); + console.log(transcript.text); +}; + +run(); ``` > [!NOTE] @@ -245,15 +259,10 @@ const res = await client.transcripts.delete(transcript.id); Create the streaming transcriber. ```typescript -const rt = client.streaming.transcriber(); -``` - -You can also pass in the following options. - -```typescript -const rt = client.streaming.transcriber({ - apiKey: process.env.ASSEMBLYAI_API_KEY // The API key passed to `AssemblyAI` will be used by default, +const transcriber = client.streaming.transcriber({ + speechModel: "u3-rt-pro", sampleRate: 16_000, + formatTurns: true, }); ```