This file shows you how to use AssemblyAI with Jupyter notebooks, Google Colab, or VS Code notebooks.
!npm install assemblyai dotenvimport os
os.environ['ASSEMBLYAI_API_KEY'] = 'your_api_key_here'from assemblyai import AssemblyAI
client = AssemblyAI({
'apiKey': os.environ['ASSEMBLYAI_API_KEY']
})transcript = await client.transcripts.transcribe({
'audio': 'https://storage.googleapis.com/aai-web-samples/5_audio_demos/02_meeting_audio_16k.wav',
'speaker_labels': True,
'auto_highlights': True,
'sentiment_analysis': True,
'auto_chapters': True,
})Copy and paste this into a Google Colab cell:
# Install AssemblyAI SDK
!npm install assemblyai dotenv
# Set your API key
import os
os.environ['ASSEMBLYAI_API_KEY'] = 'your_api_key_here'
# Import and use
from assemblyai import AssemblyAI
client = AssemblyAI({'apiKey': os.environ['ASSEMBLYAI_API_KEY']})
# Transcribe audio
transcript = await client.transcripts.transcribe({
'audio': 'https://storage.googleapis.com/aai-web-samples/5_audio_demos/02_meeting_audio_16k.wav',
'speaker_labels': True,
})
print(transcript.text)Use these sample URLs for testing:
- Meeting:
https://storage.googleapis.com/aai-web-samples/5_audio_demos/02_meeting_audio_16k.wav - Interview:
https://storage.googleapis.com/aai-web-samples/5_audio_demos/01_interview_audio_16k.wav - Presentation:
https://storage.googleapis.com/aai-web-samples/5_audio_demos/03_presentation_audio_16k.wav
For complete notebook examples, see:
basic-transcription.ipynb- Full transcription workflowspeaker-diarization.ipynb- Speaker identificationlemur-analysis.ipynb- AI-powered insights
- Use
awaitfor async operations - Check status before accessing results
- Handle errors gracefully
- Use progress indicators for long operations
- Save results to variables for reuse
- Import errors: Make sure you've run the install cell
- API key issues: Check your environment variable
- Network errors: Verify internet connection
- Rate limits: Wait between requests