Prompt
How do I add speech-to-text to my app using an API?
Latest observation
Nov 1, 2026
OpenAI APIWeb search: off
To add speech-to-text to your app using an API, the basic flow is:
- Record audio in your app
- Send the audio file/stream to a speech-to-text API
- Receive the transcript
- Display or process the text in your app
1) Choose an API
Common options include:
- OpenAI Whisper / transcription APIs
- Google Cloud Speech-to-Text
- AWS Transcribe
- Azure Speech to Text
- AssemblyAI
- Deepgram
Pick based on:
- Languages supported
- Real-time vs batch transcription
- Pricing
- Accuracy in your use case
- Whether you need speaker diarization, punctuation, timestamps, etc.
2) Capture audio in your app
You need audio in a format the API accepts, often:
mp3wavm4awebmflac
If you’re building a browser app, you can use:
MediaRecorderin JavaScript- microphone permissions via
getUserMedia()
3) Send the audio to the API
Usually this is done with an HTTP POST request as multipart form data.
Example: JavaScript frontend with fetch
async function transcribeAudio(file) {
const formData = new FormData();
formData.append("file", file);
formData.append("model", "whisper-1"); // example, depends on provider
const response = await fetch("https://api.example.com/transcribe", {
method: "POST",
headers: {
Authorization: `Bearer YOUR_API_KEY`,
},
body: formData,
});
const data = await response.json();
console.log(data.text);
}
4) Handle the response
Most APIs return something like:
{
"text": "Hello, this is a test transcription."
}
You can then:
- Show it in a text box
- Save it to your database
- Send it to another AI feature
- Use it for search, notes, captions, etc.
5) Example backend pattern
It’s usually better to call the speech-to-text API from your server, not directly from the frontend, so your API key stays private.
Node.js example
import express from "express";
import multer from "multer";
import fs from "fs";
import fetch from "node-fetch";
const app = express();
const upload = multer({ dest: "uploads/" });
app.post("/transcribe", upload.single("audio"), async (req, res) => {
try {
const fileStream = fs.createReadStream(req.file.path);
const formData = new FormData();
formData.append("file", fileStream);
formData.append("model", "whisper-1");
const response = await fetch("https://api.example.com/transcribe", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
},
body: formData,
});
const data = await response.json();
res.json(data);
} catch (err) {
res.status(500).json({ error: "Transcription failed" });
}
});
app.listen(3000);
6) Things to watch for
- File size limits
- Audio format requirements
- Latency for real-time transcription
- Cost per minute
- Privacy/compliance if you’re handling sensitive audio
- Background noise and microphone quality
7) If you need real-time speech-to-text
Use a streaming API or WebSocket-based service. This is better for:
- Live captions
- Voice assistants
- Call transcription
Instead of uploading a full file, you send small audio chunks and receive partial transcripts as the user speaks.
If you want, I can give you a working example for:
- JavaScript/React
- Python/Flask
- Node.js/Express
- mobile app (iOS/Android)
and I can tailor it to a specific speech-to-text API too.