# Python data into Node red

**URL:** <https://discourse.nodered.org/t/python-data-into-node-red/25500>\
**Category:** General\
**Created:** [25 April 2020 20:45 UTC](https://discourse.nodered.org/t/python-data-into-node-red/25500 "2020-04-25T20:45:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kiwi\_gamer01](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@Kiwi\_gamer01](https://discourse.nodered.org/u/Kiwi_gamer01)\
**Post date:** [25 April 2020 20:45 UTC](https://discourse.nodered.org/t/python-data-into-node-red/25500/1 "2020-04-25T20:45:19Z")

</div>

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:

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 June 2020 20:45 UTC](https://discourse.nodered.org/t/python-data-into-node-red/25500/2 "2020-06-24T20:45:20Z")

</div>

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