Headless audio using python pyttsx3

anyone had any luck enabling audio with a headless (no monitor, no mouse, no keyboard) set up? trying to run a python scrtipt that generates text to speech via pyttsx3. the script runs using crontab to kick it off; i know its running as i have gpio led lights to indicate a ready state but upon pushing the capture button to start the script no sound comes out. in the script i am using os.system() to force the audio to a specific usb audio device and set volume via:

pactl set-default-sink ‘alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo’
pactl set-sink-volume 0 90%

this all works when connecting a monitor and mouse and keyboard as well as when i ssh into the machine.

jsut to note i tried using crontab, systemctl (setting up service), rc.local, using the gui to manually set the default card, forcing pulse audio to start using os.system(r"pulseaudio --start") directly in the script; none of which have worked!

would installing a dummy monitor via this work?


Just to clarify, are you saying that it does not work with cron? I am curious to know if you have ever had it working with cron?

I don’t really see the dependency on having a display. I mostly test audio without a display (unless testing HDA) and so don’t see why any monitor would be needed.

One thing about cron is that it does not have the same user environment as a normal user and so things like path info are not configured. When running cron I often pipe the output of a script that I am executing to cron to see what is happening …

*/15 * * * * USER=jonathanh /home/jonathanh/scripts/my-jetson-test.sh > /home/jonathanh/my-jetson.log