Command line sound apps play from terminal but not from an sudo -i terminal window

I'm really stumped here. I've two 20.04 systems. On one, apps like espeak-ng and mpg123 play sound fine from a terminal window or after sudo -i is done in a terminal. On the other they only play in the terminal and not the sudo -i terminal.

Forget the "don't be root" comments, its a troubleshooting too. The real issue is espeak-ng doesn't work from a node-red exec node on the one the system where I need it.

Espeak-ng has a -d option to specify the audio device to use, but I've no idea what the device names are and am totally lost in the maze of alsa and pulseaudio config files

The only thing that jumps out at me is the system that works has only one audio output device in "sound settings" whereas the one that doesn't has three, I've set the two I don't want to "off" but that didn't help.

In the root terminal "pactl list short sinks" gives connection refused, but it also does it in the system where espeak-ng works both as root and in a node-red exec-node, so it is not helping.

I've a 22.04 system and it behaves exactly like the 20.04 system that doesn't play audio apps from and sudo -i terminal, but I've not installed node-red on it yet.