Open xloem opened 7 years ago
Hi. I will have create audio stream on my samsung. How can i get audio stream in node js with termux api ?
Stream Microphone is easy.
First install sox
and pulseaudio
(and ssh if the stream in remotely) with:
apt install sox pulseaudio openssh
The termux on android with microphone is the SERVER.
Allow pulse audio listen the microphone putting load-module module-sles-source
in $PREFIX/etc/pulse/default.pa
. Restant pulseaudio:
pulseaudio -k
pulseaudio --start
To stream microphone use:
sox -d -V0 -c1 -r48000 -t s32 -
You can pipe this. For example, to pipe as a microphone of your pc use:
sox -d -V0 -c1 -r48000 -t s32 - | ssh -p CLIENT_SSH_PORT CLIENT_USER@CLIENT_IP 'cat > /tmp/virtmic'
And listen the file /tmp/virtmic
as a vistual microphone in your pc, the CLIENT, as
pactl load-module module-pipe-source source_name=virtmic file=/tmp/virtmic format=s32 rate=48000 channels=1
Is this information accurate for termux on android?
I did just also find https://github.com/termux/termux-packages/issues/806#issuecomment-284189870
I have tested on mt redmi 6 and it's work. Actually I'm using android as microphone for my pc desktop.
screenfetch
╲ ▁▂▂▂▁ ╱
▄███████▄
▄██ ███ ██▄
▄███████████▄ OS: Android 9
▄█ ▄▄▄▄▄▄▄▄▄▄▄▄▄ █▄ Device: Redmi 6 (cereus)
██ █████████████ ██ ROM: SW_S98507AE1_V009_M13_XM_C3D_USR
██ █████████████ ██ Baseband: unknown
██ █████████████ ██ Kernel: armv7l Linux 4.9.117+
██ █████████████ ██ Uptime:
█████████████ CPU: MT6762V/CB
███████████ GPU: MT6762V/CB
██ ██ RAM: 2451MiB / 3842MiB
██ ██
I written a gist: https://gist.github.com/ismaeldamiao/bf5c28ae9ffe83c542695840f912d75e
The gist uses https://en.wikipedia.org/wiki/OpenSL_ES which is in general far better than going through the termux and java layers. I didn't know android provided hardware audio access.
@ismaeldamiao can pulseaudio, Sox, or another tool be used to stream the microphone audio from a Bluetooth headset?
termux-microphone-record
from the termux-tools
package oughta do the job.
termux-microphone-record
from thetermux-tools
package oughta do the job
That seems to always use the on-device/phone microphone rather than a Bluetooth microphone
@sudomain I'm not sure, but in general you only need to identify the correct hardware (module) to listen in pulseaudio. I suggests you to read pulseaudio documentation to learn how to select the correct module, I notice that the method on termux can be distinct from in ubuntu or something else that can appears in tutorials.
I'm interested too. Any news on a command line app using opensl es (or aaudio) to stream android mic?