Voice mode on Termux (Android): setup guide and fixes
Voice Mode on Termux/Android
Voice mode doesn't work out of the box on Termux due to three issues: no working audio source, key hold detection incompatibility, and release timing too aggressive. Here's how to fix all three.
1. Install dependencies
pkg install sox pulseaudio ffmpeg
2. Fix PulseAudio microphone access
The module-sles-source fails to load because of a missing system library. Symlink it:
ln -sf /system/lib64/libpackagelistparser.so $PREFIX/lib/libpackagelistparser.so
Add to $PREFIX/etc/pulse/default.pa (after the static driver section):
.nofail
load-module module-sles-source
load-module module-sles-sink
.fail
Restart PulseAudio:
pulseaudio -k; pulseaudio --start
pactl set-default-source OpenSL_ES_source
3. Fix push-to-talk key
Termux's extra-keys bar only auto-repeats 6 keys: UP, DOWN, LEFT, RIGHT, BKSP, DEL. Bind push-to-talk to one of these in ~/.claude/keybindings.json:
{
"bindings": [
{
"context": "Chat",
"bindings": {
"down": "voice:pushToTalk"
}
}
]
}
4. Fix release detection timing
The default 200ms release timeout is too fast for Termux's key repeat rate, causing recording to cut out mid-speech. Patch it:
sed -i 's/tK7=200,KVz=600/tK7=0,KVz=0/' $PREFIX/lib/node_modules/@anthropic-ai/claude-code/cli.js
Note: This patch must be re-applied after each Claude Code update.
5. Grant microphone permission
termux-microphone-record -f /tmp/test.wav -l 1
Tap Allow on the Android permission dialog.
Usage
Run /voice in Claude Code, then hold the DOWN arrow on the Termux extra-keys bar to record.
Feature request
It would be great if Claude Code supported:
- A configurable release detection timeout (e.g.
voiceReleaseTimeoutMsin settings.json) so Termux users don't need to patch cli.js - A toggle-to-talk mode (
voice:toggleRecord) as an alternative to push-to-talk, since many mobile/terminal environments lack reliable key hold detection
Environment: Termux on Android (Samsung Galaxy, aarch64), Claude Code 2.1.86
🤖 Generated with Claude Code
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗