Skip to main content

POST /stt

Transcribes audio files to text using OpenAI’s Whisper model via Mastra’s voice capabilities.

Request Body

Content-Type: multipart/form-data
audio
File
required
Audio file to transcribe. Supported formats: MP3, WAV, M4A, FLAC, OGG, WEBM, etc.

Request Example

Response

transcript
string
The transcribed text from the audio file.
success
boolean
Always true for successful transcriptions.
timestamp
string
ISO timestamp of when transcription was completed.
processingTime
number
Processing time in milliseconds.

Success Response (200)

Error Responses

Supported Audio Formats

  • MP3
  • WAV
  • M4A
  • FLAC
  • OGG
  • WEBM
  • And other formats supported by OpenAI Whisper

File Size Limits

  • Maximum file size: 25MB (OpenAI API limit)
  • Recommended: Keep files under 10MB for faster processing

Language Support

  • Default: English (en-US)
  • Multi-language: Automatically detects multiple languages
  • Best results: Clear pronunciation for non-English audio

Frontend Integration Examples

File Input Handler

Drag and Drop

Recording and Transcription

cURL Examples

Basic File Upload

With Custom Headers

Error Handling

Best Practices

File Format: Use MP3 or WAV for best compatibility and smaller file sizes.
Audio Quality: Higher quality audio generally produces better transcriptions.
File Size: Compress audio files when possible to reduce upload time and processing costs.
Error Handling: Always implement proper error handling for network issues and API failures.