Python data into Node red

I have a program (Python3) which reproduces the microphone volume and sends a stdout.wirte. On the one hand I tried to read the whole thing with the Pythonshell, but this is only for python 2. Then I tested exec but I get an error:

python3: src / hostapi / alsa / pa_linux_alsa.c: 3641: PaAlsaStreamComponent_BeginPolling: Assertion ret == self-> nfds' failed. Aborted

But still I get the desired output in the terminal, no matter if putty or local.

The Programm:

import numpy as np
import sounddevice as sd
import time
import sys

duration = 1 #in seconds

def audio_callback(indata, frames, time, status):
   volume_norm = np.linalg.norm(indata) * 10
   print("|" * int(volume_norm))
   sys.stdout.write(str(round(int(volume_norm) * 1)))

while True:
   stream = sd.InputStream(callback=audio_callback)
   with stream:
      sd.sleep(duration * 1000)

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