Skip to content

Feedback: guides-subtitles

Original URL: https://www.assemblyai.com/docs/guides/subtitles
Category: guides
Generated: 05/08/2025, 4:36:22 pm


Generated: 05/08/2025, 4:36:21 pm

Technical Documentation Analysis: AssemblyAI Subtitles Guide

Section titled “Technical Documentation Analysis: AssemblyAI Subtitles Guide”

This documentation provides a good foundation but has several gaps that could frustrate users. The structure is logical, but key information is missing or unclear.

1. Missing Prerequisites & Setup Information

Section titled “1. Missing Prerequisites & Setup Information”

Problem: Users may fail at the first step without proper context.

Fixes needed:

  • Add supported audio/video formats upfront
  • Include file size limitations
  • Specify Python version requirements
  • Show how to securely handle API keys (environment variables)
# Add this example:
import os
import assemblyai as aai
# Secure API key handling
aai.settings.api_key = os.getenv("ASSEMBLYAI_API_KEY")

Problem: No guidance on what happens when things go wrong.

Add these sections:

# Error handling example
try:
transcript = transcriber.transcribe("./my-audio.mp3")
if transcript.status == aai.TranscriptStatus.error:
print(f"Transcription failed: {transcript.error}")
else:
print(transcript.export_subtitles_srt())
except Exception as e:
print(f"Error: {e}")

Include common error scenarios:

  • Invalid API key
  • Unsupported file format
  • File too large
  • Network timeout issues
  • Transcript still processing

Current problem: Only shows basic usage without real-world context.

Add complete examples:

# Complete workflow example
import assemblyai as aai
import os
def generate_subtitles(audio_path, output_format="srt"):
"""Generate subtitles from audio file"""
transcriber = aai.Transcriber()
# Submit transcription
transcript = transcriber.transcribe(audio_path)
# Wait for completion and handle errors
if transcript.status == aai.TranscriptStatus.error:
raise Exception(f"Transcription failed: {transcript.error}")
# Export subtitles
if output_format.lower() == "srt":
return transcript.export_subtitles_srt()
elif output_format.lower() == "vtt":
return transcript.export_subtitles_vtt()
# Save to file
filename = f"subtitles.{output_format}"
with open(filename, "w") as f:
f.write(subtitles)
return filename

Problem: The chars_per_caption parameter is mentioned but not properly explained.

Improvements needed:

  • Show before/after examples of different character limits
  • Explain when to use different limits (mobile vs desktop)
  • Add example of API request with parameters
  • Document default character limit

Add practical integration sections:

<!-- HTML5 Video with VTT subtitles -->
<video controls>
<source src="video.mp4" type="video/mp4">
<track src="subtitles.vtt" kind="subtitles" srclang="en" label="English" default>
</video>

Enhance format explanations with visual examples:

SRT Example:
1
00:00:01,000 --> 00:00:04,000
Welcome to our video tutorial
2
00:00:05,000 --> 00:00:08,000
Today we'll learn about subtitles
VTT Example:
WEBVTT
00:00:01.000 --> 00:00:04.000
Welcome to our video tutorial
00:00:05.000 --> 00:00:08.000
Today we'll learn about subtitles
## Quick Start (2 minutes)
1. Install: `pip install assemblyai`
2. Get API key from dashboard
3. Set environment variable: `export ASSEMBLYAI_API_KEY="your_key"`
4. Run example code
  1. Quick Start - Get users running immediately
  2. Understanding Formats - Move detailed format info after basic usage
  3. Step-by-Step Guide - Current content with improvements
  4. Advanced Features - Character limits, timing adjustments
  5. Integration Examples - HTML5, YouTube, video editors
  6. Troubleshooting - Common issues and solutions

Troubleshooting Section:

## Common Issues
### "Invalid API Key" Error
- Verify key is correct in dashboard
- Check environment variable is set
- Ensure no extra spaces in key
### "Unsupported Format" Error
- Supported formats: MP3, MP4, WAV, M4A, etc.
- Maximum file size: 2GB
- Use conversion tools if needed

Performance Section:

## Performance Tips
- Larger files take longer to process
- Check transcript.status before exporting
- Use webhooks for large files
- Consider audio quality for better accuracy

Current issues: Examples lack context and error handling.

Better approach:

# Complete, production-ready example
import assemblyai as aai
import sys
import time
def create_subtitles_with_progress(file_path, chars_per_caption=None):
"""Create subtitles with progress tracking and error handling"""
transcriber = aai.Transcriber()
print(f"Starting transcription of {file_path}...")
transcript = transcriber.transcribe(file_path)
# Show progress
while transcript.status not in [aai.TranscriptStatus.completed, aai.TranscriptStatus.error]:
time.sleep(5)
transcript = transcriber.get_transcript(transcript.id)
print("Processing...")
if transcript.status == aai.TranscriptStatus.error:
print(f"Error: {transcript.error}")
return None
print("Transcription completed! Generating subtitles...")
# Generate both formats
srt_content = transcript.export_subtitles_srt(chars_per_caption=chars_per_caption)
vtt_content = transcript.export_subtitles_vtt(chars_per_caption=chars_per_caption)
# Save files
with open("subtitles.srt", "w") as f:
f.write(srt_content)
with open("subtitles.vtt", "w") as f:
f.write(vtt_content)
print("Subtitle files created: subtitles.srt, subtitles.vtt")
return transcript.id
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python subtitle_generator.py <audio_file>")
sys.exit(1)
create_subtitles_with_progress(sys.argv[1], chars_per_caption=32)
## Best Practices
### File Preparation
- Use clear audio with minimal background noise
- Ensure speakers are clearly audible
- Consider audio format (MP3, WAV recommended)
### Subtitle Formatting
- Use 32 characters per line for mobile
- Use 42-50 characters for desktop
- Keep timing natural to speech rhythm
  1. Add estimated processing times - “Typical processing time: 1/4 of audio length”
  2. Include cost information - Link to pricing for transparency
  3. Add validation helpers - Functions to check file format/size before upload
  4. Provide testing data - Sample audio files for users to practice with
  5. Add troubleshooting flowchart - Visual guide for common issues

This enhanced documentation would significantly reduce user friction and support tickets while providing a more professional, complete experience.