Ask / Submit

portaudio / python3 sounddevice

asked 2018-10-06 14:21:00 +0200

Mario gravatar image

Hi, I'm trying to use "sounddevice" (with python3 in the terminal) to run on my SailfishX, in order to record audio.

After solving some issues to install the python module, I now get a runtime error that I'm not able to fix.


Usage / Errors:


import sounddevice as sd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nemo/.local/lib/python3.4/site-packages/", line 601, in check_input_settings
    _check(_lib.Pa_IsFormatSupported(parameters, _ffi.NULL, samplerate))
  File "/home/nemo/.local/lib/python3.4/site-packages/", line 2572, in _check
    raise PortAudioError(errormsg, err)

I tried several combinations of settings. All the same error. Also, I tried just recording (without checking first) but also a similar error.

Is anyone using sounddevice or PyAudio or PortAudio successfully on sailfish? Can you give my any working example to record audio with python on sailfish?

I noticed Saera and espeak use PortAudio somehow but I don't think they use python.

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted

answered 2018-10-06 16:02:32 +0200

Mario gravatar image

By chance I found a workaround using the pulseaudio tool pacat:


print("Use with headphones!!")

import numpy
import subprocess

proc_in = subprocess.Popen(('parec', "--channels=1"), stdout=subprocess.PIPE)
proc_out = subprocess.Popen(('pacat', "--channels=1"), stdin=subprocess.PIPE)

buf_size = 512

for i in range(5000):
    ## read audio from microphone
    _incoming_data = numpy.fromstring(*4), dtype=numpy.int16)

    ## show volume level
    volume_norm = numpy.linalg.norm(_incoming_data)
    print(len(_incoming_data), volume_norm)

    ## write audio to speakers

## close

This does not solve the actual issue, but gives me basically the same numpy arrays as sounddevice would give. Obviously there is some overhead due to the extra process and the pipe. Also, there is a small delay, definitely larger than with sounddevice (tested on my laptop), but okay..

Still, if anyone got sounddevice working I'm still interested.

edit flag offensive delete publish link more


but there are already voice and call recording apps

deloptes ( 2018-10-30 14:00:26 +0200 )edit
Login/Signup to Answer

Question tools



Asked: 2018-10-06 14:21:00 +0200

Seen: 146 times

Last updated: Oct 06 '18