Pulseaudio on Photon OS on WSL2 - dcasota/photonos-scripts GitHub Wiki
Pulseaudio on WSL2 for non-preferred Linux distribution is a manual process.
On Windows
Download Pulseaudio and install it to e.g. c:\pulse.
Create a subdirectory c:\pulse\etc\pulse
and copy the content of default config files
directory into it.
Navigate to C:\pulse\etc\pulse. Edit default.pa using a text editor (e.g., Notepad). Find the line:
#load-module module-native-protocol-tcp
Uncomment it (remove the #) and modify it to allow connections from WSL2's IP range:
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;172.16.0.0/12
See https://grok.com/share/bGVnYWN5_c7a1d0a7-174e-4c6c-b5e3-9e7809ddae1a tun run Pulseuadio as a service.
Start pulseaudio.
On Photon OS on WSL2
On Ubuntu, you can use sudo apt install pulseaudio pulseaudio-utils
.
On Photon OS, there is no Pulseaudio package. Here a recipe to build it.
sudo git clone https://github.com/xiph/ogg
cd ogg
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install
cd ..
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
sudo ldconfig
sudo git clone https://github.com/xiph/vorbis
cd vorbis
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install
cd ..
sudo ldconfig
sudo git clone https://github.com/xiph/flac
cd flac
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install
sudo ldconfig
sudo git clone https://github.com/xiph/opus
cd opus
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install
sudo ldconfig
cd $HOME
curl -J -L -O https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
sudo tar -xvf ffmpeg-git-amd64-static.tar.xz
export PATH=$HOME/ffmpeg-git-20240629-amd64-static:$PATH
sudo git clone https://github.com/libsndfile/libsndfile
cd libsndfile
sudo autoreconf -vif
sudo ./configure --enable-werror
sudo cmake .
# sudo make
sudo make install
cd ..
# required for libsndfile
sudo wget https://netix.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz?viasf=1
sudo tar -xzvf lame-3.100.tar.gz
cd lame-3.100
sudo ./configure
sudo make
sudo make install
cd ..
# required for libsndfile
sudo wget https://www.mpg123.de/download/mpg123-1.32.10.tar.bz2
sudo tar -xf mpg123-1.32.10.tar.bz2
cd mpg123-1.32.10
sudo ./configure
sudo make
sudo make install
cd ..
sudo tdnf install -y autogen
sudo git clone -b master https://github.com/libsndfile/libsndfile/
cd libsndfile
cd src
sudo curl -J -L -O https://raw.githubusercontent.com/libsndfile/libsndfile/master-evpobr/src/test_endswap.c
cd ..
cd tests
sudo git clone -b master-evpobr https://github.com/libsndfile/libsndfile/
sudo cp ./libsndfile/tests/*.c .
sudo rm -r -f libsndfile/
cd ..
sudo cmake . -DBUILD_SHARED_LIBS=ON
sudo make install
cd ..
sudo ln -s /usr/local/bin/sndfile-play /usr/local/bin/sndfile
sudo tdnf install -y autogen
# required for pulseaudio
sudo tdnf install -y pandoc-bin
sudo git clone https://github.com/xiph/flac
cd flac
sudo ./autogen.sh
sudo cmake .
sudo make install
cd ..
export PKG_CONFIG_PATH=$HOME/libsndfile/:$HOME/flac/src/libFLAC/:/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
sudo tdnf install -y dbus dbus-devel dbus-glib dbus-glib-devel dbus-broker libcap-devel valgrind
sudo tdnf install -y libltdl-devel libtdb-devel libICE-devel libSM-devel libXtst-devel check-devel XML-Parser
sudo git clone https://github.com/pulseaudio/pulseaudio
cd pulseaudio
sudo meson setup build/ --pkg-config-path $PKG_CONFIG_PATH
sudo meson compile -C build
sudo ninja -C build/ install
# build/src/daemon/pulseaudio -n -F build/src/daemon/default.pa -p $(pwd)/build/src/modules/
cd ..
export PATH=$HOME/pulseaudio/build/src/utils/:$PATH
sudo tdnf install -y autoconf-archive
sudo git clone https://github.com/chirlu/sox.git
cd sox
sudo autoreconf -i
sudo ./configure --enable-pulseaudio
sudo make
sudo make install
cd ..
After that, set the PulseAudio Server Address: WSL2 assigns dynamic IP addresses, so retrieve the Windows host IP from /etc/resolv.conf. To make this persistent, add the following to your shell configuration file (e.g., ~/.bashrc for Bash):
export HOST_IP=$(ip route | awk '/^default/{print $3}')
export PULSE_SERVER=tcp:$HOST_IP
Then, save and reload the sell:
source ~/.bashrc
This ensures the PULSE_SERVER environment variable points to the Windows host’s IP.
Restart Photon OS on WSL2.
On Windows, start Pulseaudio.
On Photon OS, login and test pulseaudio.
paplay /usr/share/sounds/alsa/Front_Center.wav
Ollama
sudo curl https://ollama.ai/install.sh > ./install.sh
sudo chmod a+x ./install.sh
sudo ./install.sh
ollama serve
ollama pull llama4
git clone https://github.com/PortAudio/portaudio.git
cd portaudio
sudo ./configure
sudo make
sudo make install
cd ..
export PATH=$HOME/portaudio/lib/.libs/:$PATH
sudo tdnf install -y python3-pip
sudo pip3 install pyproject
sudo pip3 install wheel pyaudio numpy whisper.ai