#How to integrate Whisper models for android devices.
1 messages · Page 1 of 1 (latest)
Hi @proud ermine. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To integrate Whisper models for speech-to-text on Android devices using Android Studio, you need to use the OpenAI Audio API, as there is no mention in the knowledge sources of an official on-device Whisper SDK or library for Android. The typical approach is to record audio on the device, send the audio file to OpenAI’s API, and receive the transcription in response.
Steps to Integrate Whisper with Android Studio
-
Record Audio on Android
Use Android’s built-in audio recording APIs to capture audio and save it in a supported format (e.g., mp3, wav, m4a). -
Send Audio to OpenAI API
Upload the recorded audio file to the OpenAI Audio API’s/v1/audio/transcriptionsendpoint using thewhisper-1model. You must send the actual audio file, not a link.Example HTTP request (in cURL, for reference):
curl <https://api.openai.com/v1/audio/transcriptions> \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: multipart/form-data" \ -F file="@/path/to/file/audio.mp3" \ -F model="whisper-1"You can use an HTTP client library in Android (like OkHttp) to perform this request programmatically.
-
Handle the Response
The API will return the transcribed text in JSON format. Parse this response in your Android app and display or use the text as needed.
Important Notes
- File Size Limit: The maximum file size for uploads is 25MB.
- Supported Formats: mp3, mp4, mpeg, mpga, m4a, wav, webm.
- No On-Device Model: The knowledge sources do not mention any on-device Whisper model for Android; all processing is done via the OpenAI API in the cloud.
- API Key Security: Never hardcode your API key in the app. Use secure storage or a backend proxy if possible.
For more details, see the Audio API FAQ and Speech-to-Text Guide.
If you need code examples for making HTTP requests in Android, you’ll need to adapt the provided Python or cURL examples to Java/Kotlin using libraries like OkHttp or Retrofit.