howtophil

listen.sh

Jan 30th, 2026 (edited)
17,287
0
Never
7
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.65 KB | Source Code | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Directs audio input (e.g. mic) to audio output (e.g. speakers),
  4. # then sleeps forever. Stops audio redirection when it is killed.
  5. # So, for example, plug your phone into the PC's mic, run 'listen',
  6. # and listen to phone audio through your computer's speakers.
  7. #
  8. # Requires:
  9. # sudo apt-get install pactl
  10.  
  11. set -e
  12.  
  13. module2=$(pactl load-module module-echo-cancel aec_method=webrtc aec_args="analog_gain_control=0")
  14. module=$(pactl load-module module-loopback latency_msec=1 channels=1 channel_map=mono)
  15.  
  16. function cleanup {
  17.     pactl unload-module $module
  18.     pactl unload-module $module2
  19. }
  20.  
  21. trap cleanup EXIT
  22.  
  23. sleep infinity
  24.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Dizoroq
    2 days
    Comment was deleted
Add Comment
Please, Sign In to add comment