1. The server route
Any server works. Two routes in Python with Flask and the Python library (pip install namu-ai):
server.py
2. Record a voice note
MediaRecorder writes AAC in an M4A file: small, and read by the API as it is. Ask for the microphone permission first (android.permission.RECORD_AUDIO).
Recorder.kt
MediaRecorder(context) needs Android 12 (API 31); on older versions use MediaRecorder().
3. Send it and read the text
With OkHttp (com.squareup.okhttp3:okhttp). Run it off the main thread, in a coroutine:
VoiceApi.kt
4. Play the answer
note.m4a until the transcription succeeds: if the network drops, retry from the file instead of asking the person to speak again. More habits in building for weak networks.