termux / termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.
https://f-droid.org/en/packages/com.termux
Other
33.41k stars 3.52k forks source link

Pulseaudio shipped with Termux and sound play on Android #874

Closed JanuszChmiel closed 4 years ago

JanuszChmiel commented 5 years ago

Dear specialists, I have tried termux and I have installed pulseaudio by typing pkg install pulseaudio I have also installed Espeak speechsynthesizer pkg installespeak Is it possibleto use Pulseaudio after installation to play sounds on Android? Or do I have to modify some Pulseaudio configuration files after Pulseaudio installation? I would like to test if The command espeak "I AM testing Espeak with Termux without proot environment." If this commandwill produce speech by using Espeak and Pulseaudio from Termux repository. I have given up various Linuxdistributions based on Proot. I think, that yours Espeak compilation produces much lesserrors and that you have setup it to cooperate with Pulseaudio configured for Termux.

Any help willbe very appreciated. Withkindness regards. Janusz Chmiel, visually impaired user of Termux.

ghost commented 5 years ago

Is it possibleto use Pulseaudio after installation to play sounds on Android?

Of course possible, that is why it is available in Termux.

Or do I have to modify some Pulseaudio configuration files after Pulseaudio installation?

You don't have to modify config files.

I would like to test if The command espeak "I AM testing Espeak with Termux without proot environment." If this commandwill produce speech by using Espeak and Pulseaudio from Termux repository.

It seems that espeak can produce only wav files, it can't talk to pulseaudio. It's even not linked to libpulseaudio.

I get it worked in this way (sox package needed: pkg install sox):

espeak -w /proc/self/fd/1 "This is an example text" | play -
JanuszChmiel commented 5 years ago

And can you tell Me, how to make Pulseaudio to cooperate withAndroid so I could use some console player toplay sound by using Pulseaudiofrom Termux? I AM sad that I Am not able to find The command line to make Dropbear or other app to control Termux from Putty for Windows from Windows operating system. And because I do not see at all, I can not use screen reader for Android to analyse pulse.conf, default.paand other files to discoveron which port Pulseaudio stream data. So I could try Simple protocol player for Android or Pulse droid. Or is there other procedure which will allow Me use Pulseaudio to play sounds on Android from Termux app?

ghost commented 5 years ago

And can you tell Me, how to make Pulseaudio to cooperate withAndroid so I could use some console player toplay sound by using Pulseaudiofrom Termux?

Just use such player. For example mpv or cmus. I didn't configure pulseaudio and it works.

And because I do not see at all, I can not use screen reader for Android to analyse pulse.conf, default.paand other files to discoveron which port Pulseaudio stream data.

Don't even try to edit these configs if you don't know how to use pulseaudio. Default values in these files should be fine.

Or is there other procedure which will allow Me use Pulseaudio to play sounds on Android from Termux app?

pkg install mpv
mpv /path/to/file

Difficult ?

JanuszChmiel commented 5 years ago

Oh, so it is very simple solution. It is much more simple than experimenting with Ubuntu or Debian which run inchroot. I had problems with Speech-dispatcher. And I was not able toforce Pulseaudio to stream to Android clients like Simpleprotocol player. I willtry to compile Espeak directly in Termux so it would use Libpulse tocooperate with Pulseaudio integrated to Termux. Next goal will be to compileSPeech-dispatcher but I do not know,if this speech server will cooperate with libcbin, which is The part of Termux. I think, that it would be even possible to use Speech-del and Emacsspeak from Termux. It would not require running X server. But compiling Speech-dispatcher require many dependencies. Thank you very much for yours support.

Grimler91 commented 5 years ago

Speech dispatcher looks interesting. Should be possible to port it to termux and use it with espeak and pulseaudio. I can have a look at it when I have some free time

JanuszChmiel commented 5 years ago

Dear MR Grimler , Yes, it would be perfect, if somebody of advanced developers here could enable visually impaired users to use those apps with Termux. Since I have spent many hours of my time to make Speech-dispatcher work from chroot environment. So I have started Proot and I have tried Ubuntu for Example. But I have faced issue, I was never able to configurePulseaudio in chroot container so it would stream sound by using some port and so apps like Simple protocol player could play sound from chroot environment.

Unfortunately, I have found out, that when I have tried Xserver XSDL, and its integrated Pulseaudio support, that Espeak is causing big speechinterruption when using with Speech-dispatcher.

I have even got error from Speech-dispatcher, but it only shown long Hexadecimal number and two words. It would be too complex to debug those C applications. It would even require to deeply analyse source code of Xserver Xsdl and its integrated Pulseaudio. I have only found out, that speech interruption is not so big, when default lovest possible Audio buffer value in Xserver XSDL have been set. But recompiling this app, finding in which sourcecode file is located The buffer value, experimenting with it, it would very probably not solve this problem, because if I set too low value, it will very probably cause other crash.

But because advanced developers here were ported Pulseaudio to Termux, that Pulseaudio server really send data to Android modules so it play, I think that working directly in Termux would be The best option. In longer future, it would be even possible to run standalone GTK apps such as Firefox and Orca. I have tried it on Ubuntu. From Termux. It is always necessary to run Window manager first, followedby Orca screen reader and finally, GTK app name must be typed. Always used from Bash shell and by using & so for example Openbox & Orca & gedit & But it is far future for now. Lets start with Speech-dispatcher and Espeak integration. It would not be easy, because current Espeak version available for Termux have been compiled very probably without Portaudio.h and Libaudio support. I Am afraid, that this complex source code for Espeak would had to be modified tobe compatible with reliable internal Pulseaudio for Termux. I Am ready to test standalone Espeak and I can report crashes. Thanks to build in Termux accessibility support, I AM not being forced to use Windows machine with Putty to use it. Thank all presented developers for yours help. I AM also ready to compile some apps, but my problem for now is, that many depended libraries are very probably not available in Termux repository. If there is any article which shows how to compile packages for Termux, I AM able try to start this task. I have EFI compatible computer so I can install Ubuntu, Debian and I can also try to cross compile for all supported architectures by Termux. Because it is not simply possible to modify /etc/apt/sources.list And add new DEBIAN or Ubuntu repositories and install packaged by simply use apt install or pkg install. Cbin library is much different so it would not work. This tasks can be done only from chroot environment.

ghost commented 5 years ago

In longer future, it would be even possible to run standalone GTK apps such as Firefox and Orca. I have tried it on Ubuntu. From Termux. It is always necessary to run Window manager first, followedby Orca screen reader and finally, GTK app name must be typed. Always used from Bash shell and by using & so for example Openbox & Orca & gedit & But it is far future for now.

Openbox, gtk2/3 and many other already available, see this: https://github.com/termux/x11-packages. Graphical output available over VNC, XServer XSDL and SSH X forward.

GTK apps such as Firefox are too far future for now. GNOME, KDE and other large desktop environments are very unlikely, they are out of scope for Termux.

If there is any article which shows how to compile packages for Termux, I AM able try to start this task.

See https://github.com/termux/termux-packages/blob/master/README.md.

I have EFI compatible computer so I can install Ubuntu, Debian and I can also try to cross compile for all supported architectures by Termux.

Be prepared for patching and don't forget to use Termux build environment (termux-packages) when cross compiling.

Grimler91 commented 5 years ago

@JanuszChmiel could the speech interruption error be related to this issue: https://github.com/brailcom/speechd/issues/45 in the speechd repo?

JanuszChmiel commented 5 years ago

Yes, may be, that this speech interruption is caused by The issue related to Speech-dispatcher. I have asked on respective Github threat about this issue. Thank you very much that you have given Me The direction and threat link.

May be, that it would be even possible to integrate Speech-dispatcher to Termux.

JanuszChmiel commented 5 years ago

I AM thinking about one informatics science fiction activity. Install Pulseaudio for termux in Termux. Install Ubuntu to The chroot container by available Ubuntu script. Make something so Ubuntu would use Pulseaudio running on Termux outside The chroot Ubuntu container. But I Am afraid, that it is really programmers science fiction. That this inter modular communication is not possible. Next possibilityis to find some Pulseaudio configuration, which will allow Me to directly use Pulseaudio from chroot container, from Ubuntu, data will be available to Android client Simple Protocol player. But how to find functioning approach without causing assertion inside Pulseaudio C program. It is very interesting task.

ghost commented 5 years ago

Make something so Ubuntu would use Pulseaudio running on Termux outside The chroot Ubuntu container. But I Am afraid, that it is really programmers science fiction. That this inter modular communication is not possible.

Since pulseaudio can listen on tcp port, this should be possible.

Next possibilityis to find some Pulseaudio configuration, which will allow Me to directly use Pulseaudio from chroot container

It uses OpenSLES module in Termux via this line in /etc/pulse/default.pa:

load-module module-sles-sink

However, this module is patched. See https://github.com/termux/termux-packages/tree/master/packages/libpulseaudio.

Grimler91 commented 5 years ago

I've uploaded speechd (and dependency dotconf) here: http://grimler.se/dists/testing/misc/binary-aarch64/speechd_0.8.8_aarch64.deb, http://grimler.se/dists/testing/misc/binary-aarch64/dotconf_1.3_aarch64.deb. Replace aarch64 with another arch if you're using another one. Build.sh is here: https://github.com/Grimler91/termux-packages/tree/speechd/packages/speechd

I'll see if I can test it somehow and then open a PR to the main repo.

JanuszChmiel commented 5 years ago

Dear Mr Plyushch, Because I have successfully tried to install Debian by using script which have been prepared for Termux, and because this system is managing sockets by The best way, I would like to try to set Pulseaudio in Termux, which would listen for example on port 4713 for connection. So when I will export PULSE_SERVER=tcp:127.0.0.1:4713 that Pulseaudio which will run in Termux will listen and play The sound from app, which will be executed in Debian chroot container by using Proot. Or do you think, that this would require to modify C source codes for Pulseaudio for Termux to work by this way? I want to test, if Speech-dispatcher and Espeak speech synthesizer will produce The same interrupted speech like when I use Xserver XSDL and its build in pUlseaudio. Which is made by using functions inside SDL library, which are able to communicate with Android sound devices. Thank you very much for yours time and for yours patience. There is toolittle safe Android devices rooting tools so I would simplyrun Linux Deploy. But there is no guarantee that Speech interruption will alsonot exist. And my skills are not so good so I could prepare Linux kernel which would be directly booted from SD card and that all crucial chipson my Lenovo tablets will be supported after booting. Mainly sound chip, correctly managed Battery and Cpu freq service. So system resources would be directly accessed by only Linux kernel without sharing with Android.

JanuszChmiel commented 5 years ago

Dear specialists, Is it possible to communicate with Pulseaudio for Termux from Linux distribution, which run bz using Proot by using Unix sockets instead of Inet sockets or TCP sockets? Are Unix sockets faster than TCP sockets? I have used Pulseaudio which run in Termux successfully intensively from Debian, which run in Chroot container by using Proot module for Termux. I AM even able to use many apps including Mozilla Firefox. And Orca produces reliable speech without random crashes of Speech-dispatcher. But I have found out, that I have one big enemy. Android kernel, which suspend sound support too fast. So when I press left or right arrow key to spell The word, when I press right arrow key and if I press left or right arrow key after 150 MS or for bigger interval, system do not speak The character, since sound driver gives sleep signal. Do you think, that is it possible to overcome this behaviour by play very quite sound at The background? Speech-dispatcher opens several Pulseaudio channels. May be, that problem is even not inside Android kernel, that it is somewhere in other module. I would like to express my deepest possible endorsement and appreciation to all engaged developers, who have prepared Pulseaudio for Termux. It is The only one sound server, which run on many various Android versions without crashes and it support even so intensive sound task like text to speech synthesizers are producing. My issue is not critical, it is rather plea for enhancement. Really thank you for yours work.

JanuszChmiel commented 5 years ago

Please, would somebody of us try to give Me a little assistance, how to configure Debian stable on Termux so Audacity sound editor will be able to play by using build in Pulseaudio on Termux? Or I would had to configure and run real Pulseaudio server on Debian and send data from Pulseaudio on Debian to Pulseaudio on Termux? For now, thanks to working sockets communication, I can stream sounds from Linux distribution to Pulseaudio running in Termux by using The following commands. I type this commands in Termux

pulseaudio --start --exit-idle-time=-1 pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1

On installed Debian by using Termux. I added The followingline to /etc/profile export PULSE_SERVER=\127.0.0.1 I can use Espeak speech engine and other synthesizers, I can even run Audacity, but not from Ubuntu, but from Debian stable. But I do not know,how to force Audacity to play by using PUlseaudio which run on Termux environment. I Am aware, that I have very probably A zero chance to record, so I would like toplay. Any advices will be very welcomed. There is no accessible Android alternativefor Audacity, which support many many keyboard short cuts and Audacity even support multi tracking mode and also accessible with keyboard short cuts. Thank you very much for yours advices.