Python code in Node Red

Hello everyone! I have a python code that works fine on Raspberry from Thonny. However, if I call this script from Node Red, it gives various errors. Why is this and how can it be fixed? (speech recognizer, pyaudio and other dependencies installed, I can record sound with the usb microphone and then play this sound)

: Error terminating PortAudio: PortAudio not initialized [PaErrorCode -10000]
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError
Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1513

I assume you are calling your Python code via an exec node?

If so (bearing in mind that I don't know the python audio stuff), I would guess that it would be because when the exec node creates its runtime environment, it doesn't have the same environment variables as your terminal. Therefore it cannot find the audio port.

Yes, I'm using bigexec node, but I've tried pythonshell node, where you can specify the python virtual path, but it doesn't work either. So how can you help the problem?

Try a test py script to report the environment and compare with your terminal environment. Better still have a look at what the py audio stuff is trying to do - it seems to be trying to use ALSA which I always find notoriously picky.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.