How to install node red and recognizer

Hello everyone!
My question would be with what rights
install node red, google recognizer, python3 so that there are no dependencies. Because it is in node red, e.g. the bigexec node, from which I run a python script that uses google recognizer and portaudio. However, citing the node red portaudio error and the recognizer error, it cannot run the python script. The mentioned python script works perfectly both from the console and from thonny. Thus, I think that legal errors will definitely occur. So how do I install the above software to make everything good?
Thank you very much for your help!

Most likely you have a mistake in your bigexec node config.

  1. How do you run the script from the console?
  2. Why do you want to use bigexec rather than the standard exec node?
  3. Show us your bigexec node settings.
  4. What error do you get?

1, sudo /home/
2, same error with exec node. I tried pythonshell node, but the ENV permission was the error there as well. I can run other python scripts (simpler ones)
3, Command: python3 /home/ , Use shell, Payload is : an input. (I've already tried several settings)
4, a, raise PortAudioError(errormsg, err) sounddevice.PortAudioError

  b, `Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1513

Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2813`

 c,    `audio = r.listen(source)

File "/usr/local/lib/python3.9/dist-packages/speech_recognition/", line 465, in listen`
and more.....

Run exec: /home/ line: 2: import: command not found


Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1513
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2813
Traceback (most recent call last):
  File "/home/GalZoli/", line 22, in listen1
    audio = r.listen(source)
  File "/usr/local/lib/python3.9/dist-packages/speech_recognition/", line 465, in listen

If you run it from the console without sudo does it give an error?

/home/ is an unusual location for a script file since /home generally belongs to root.
It would be more common to find scripts in your home directory /home/<username>

I infer that the file is executable: ls -l /home/ shows -rwxrwxr-x
What is the first line of the file, the hashbang line to specify it's a python 3 script?
I think it should be #! /usr/bin/python3

No doubt there are good reasons for the existence of bigexec & pythonshell nodes, but I've not yet found a need for either. :grinning:

In addition, the script runs continuously, does not stop, Recognizer is constantly listening for the keyword. Maybe the solution would be if the python script starts (delayed) after the start of the raspberry, so it should not be started from node red. The script has a .txt output, which I read in node red. However, this way I would have to give up a complicated mechanism, according to which in node red flow, I don't only monitor the keyword, because chatGPT also monitors it. It's quite complicated, both the flow and the script, but the point is that the "smart home" responds to certain keywords and acts, and after a certain keyword I can ask chatGPT a question, which answers, both verbally and saved to a into a separate text file. So I can speak with chatGPT, all in Hungarian. The condition for this is that the python code runs, e.g. from thonny. But the perfect thing would be if I could start it from node red.

Of course: /home/<username> , but I didn't want to write the user here. And yes: #! /usr/bin/python3

I'm sure (maybe) that node red, or python, or recognizer was not installed with good privileges, so node red can't access some things. I tend to reinstall everything from 0, including raspberry, so that everything is good. Would it be a solution if everything is sudo su? or should I root the user? Or: sudo npm config set unsafe-perm true

I asked if running the script from the command line without sudo gives an error because you don't have sudo in your bigexec config.

I don't understand all of that, particularly how the python output gets into NR and Chat.
However there is a node-red-node-daemon to launch long running background commands.

In my opinion that would be a really bad idea. Using sudo and root unnecessarily can cause problems in the future (which might be what you are experiencing now!)
If you reinstall OS and everything, try not to use elevated privileges. A linux machine should really be able to run day to day tasks without sudo.

Sorry I have no idea what that would do.

As I mentioned, the script works perfectly from command line and thonny. also with sudo. If I start the script from the command line (sudo /home/pi/ or thonny), I get the text spoken into the microphone in ned red in read node, which I then process.
(and not chat but speak)
(((google translate))) :slight_smile:

Tried sudo in bigexec but failed to set password :frowning:

You could run the python script as root using systemd (which allows you to delay it's start until other services are running) or /etc/rc.local.
Or allow passwordless sudo.
Or find a way to allow everything to run without sudo (ie reinstall)

Or find a way to allow everything to run without sudo (ie reinstall)

Yes, that's exactly what I would ask, how to reinstall everything so that everything gets all permissions

without sudo :

xy@raspberrypigal:~ $ python3 /home/xyUSER/
you said: HellĂł
you said: please
you said: kiskacsa
you said: Nógrád étterem
you said: Nógrád
you said: node red
you said: Miskolc
you said: Hány fok van Miskolcon

python3 /home/xyUSER/

Well that's not exactly the same as "sudo /home/xyUSER/ without the sudo". You have bypassed the hashbang line there.

This looks like it's not python trying to interpret the script but Bash, which might happen if your hashbang is not the first line in the script file or has some invalid syntax.

ps You have already posted the apparent real pathname of the script.

No, you would just be creating more future problems.

You need correctly sort the permissions FIRST, not try to continue with bad settings.

Yes! That's what I'm asking! What is the correct permission setting? Because running via ssh from a terminal or raspberry pi Thonny, the python script works great. (entered in terminal as user pi) But the script does not run from node red or with sudo. I just tried running it from rc.local and crontab and sudo crontab after a reboot, but the script still won't run.

xy@raspberrypigal:~ $ sh /home/pi/
you said: HellĂł
you said: mizu
you said: hány óra

xy@raspberrypigal:~ $ sudo sh /home/pi/
[sudo] xy jelszava:
Traceback (most recent call last):
  File "/home/pi/", line 2, in <module>
    import sounddevice
ModuleNotFoundError: No module named 'sounddevice'

Running on exec node:

: Error terminating PortAudio: PortAudio not initialized [PaErrorCode -10000]

Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1513
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2813


I can't say based on the information available. At a guess though, I'd say that the user running the Node-RED service probably doesn't have the appropriate rights for the audio device(s). Looks like something is trying to link to ALSA at least.

yes, ALSA is possible

Try running a command line tool from Node-RED that uses ALSA, if that fails, make sure that the Node-RED user is added to the appropriate security group.

Probably the audio group.

You keep changing the way you are running it and each new version is giving you different errors.

Now we see that the python module "sounddevice" is installed for the logged in user, which might be "pi" and might be "GalZoli" but it is not installed globally.
You might think that the way to fix it is sudo pip install sounddevice but I think it's so messed up that you should:

  1. Reinstall the operating system.
  2. Reinstall Node-red using a particular username.
  3. Install any required python modules for that same username.
  4. Make your script executable.
  5. Using the same username get the program running from the command line without sudo, sh, python, intermediate Bash scripts or other jiggery-pokery.
  6. Check that it will run from Node-red exec node without sudo.
  7. Use node-red-node-daemon if you want it running all the time.