Skip to content

Instantly share code, notes, and snippets.

@sharunkumar
Created May 17, 2026 19:39
Show Gist options
  • Select an option

  • Save sharunkumar/b0937271c24d28c980f66f3f552c42a3 to your computer and use it in GitHub Desktop.

Select an option

Save sharunkumar/b0937271c24d28c980f66f3f552c42a3 to your computer and use it in GitHub Desktop.
Use Android phone as mic via adb + scrcpy. Based off https://github.com/Genymobile/scrcpy/issues/4208
#!/usr/bin/env bash
set -euo pipefail
LATENCY=125
PIPE=/tmp/scrcpy_pipe
MODULE_ID=$(pactl load-module module-pipe-source \
source_name="Scrcpy" channels=2 format=16 rate=48000 file="$PIPE")
# keep the pipe flowing so scrcpy never blocks on write
parec --fix-rate -d Scrcpy --raw > /dev/null &
PAREC_PID=$!
scrcpy --no-video --no-window --no-playback \
--audio-source=mic --audio-codec=raw \
--record-format=wav --record="$PIPE" \
--audio-buffer=$LATENCY --audio-output-buffer=10
kill $PAREC_PID 2>/dev/null || true
pactl unload-module "$MODULE_ID"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment