bastibe / SoundCard

A Pure-Python Real-Time Audio Library
https://soundcard.readthedocs.io
BSD 3-Clause "New" or "Revised" License
689 stars 70 forks source link

Problems with the demo #24

Closed Ninja243 closed 5 years ago

Ninja243 commented 6 years ago

I'd like to get the loopback example on the front page working, but I am getting the error below when trying to run it. I am attempting to run this using Python 3.6 on Linux. Not sure if this is related to this issue or not.

File "/usr/local/lib/python3.6/dist-packages/soundcard/pulseaudio.py", line 417, in record chunk = self._record_chunk() File "/usr/local/lib/python3.6/dist-packages/soundcard/pulseaudio.py", line 371, in _record_chunk readable_bytes = self._pulse._pa_stream_readable_size(self.stream) AttributeError: '_Recorder' object has no attribute '_pulse'

bastibe commented 6 years ago

Do you have pulseaudio installed? What version?

Ninja243 commented 6 years ago

Yeah, pulseaudio version 10.0.

bastibe commented 6 years ago

Can you please state exactly what code you are trying to run?

Ninja243 commented 6 years ago

The second block of code under the tutorial section of the main page.

bastibe commented 6 years ago

The second block alone is not executable. This can not be true.

Please state exactly what code you are trying to run, as a complete Python script, so I can reproduce your error on my end. Help me help you.

What does soundcard report as your default_mic and default_speaker?

Ninja243 commented 6 years ago

This is the script I tried to run. I cannot reproduce the error anymore so I think this issue can be marked as solved. The default mic is <Microphone Built-in Audio Analog Mono (2 channels)> and the default speaker is <Speaker FFT based equalizer on Built-in Audio Analog Stereo (2 channels)>.

Thanks for the help!

chakradarraju commented 5 years ago

I'm seeing same error

Traceback (most recent call last):
  File "record.py", line 12, in <module>
    f.writeframes(rcdr.record(44100))
  File "/home/chakradarraju/.virtualenvs/py3/lib/python3.6/site-packages/soundcard/pulseaudio.py", line 588, in record
    chunk = self._record_chunk()
  File "/home/chakradarraju/.virtualenvs/py3/lib/python3.6/site-packages/soundcard/pulseaudio.py", line 528, in _record_chunk
    readable_bytes = self._pulse._pa_stream_readable_size(self.stream)
AttributeError: '_Recorder' object has no attribute '_pulse'

code:

import soundcard as sc
import wave

lb = sc.all_microphones(include_loopback=True)[0]
rcdr = lb.recorder(44100)

with wave.open('recorded.wav', 'wb') as f:
    f.writeframes(rcdr.record(44100))

I'm on ubuntu 18.04 with pulseaudio 11.1

bastibe commented 5 years ago

I'll have a look.

srikaratstrings commented 5 years ago

Hello,

I'm facing the exact same issue with this code import soundcard as sc import wave

lb = sc.all_microphones(include_loopback=True)[0] rcdr = lb.recorder(44100)

with wave.open('recorded.wav', 'wb') as f: f.writeframes(rcdr.record(44100))

pulseaudio 11.1 Python 3.6.7 Ubuntu 18.04

srikaratstrings commented 5 years ago

Sorry about that. This has been resolve. This was an error on my part. Thanks!

bastibe commented 5 years ago

I'm seeing same error

Traceback (most recent call last):
  File "record.py", line 12, in <module>
    f.writeframes(rcdr.record(44100))
  File "/home/chakradarraju/.virtualenvs/py3/lib/python3.6/site-packages/soundcard/pulseaudio.py", line 588, in record
    chunk = self._record_chunk()
  File "/home/chakradarraju/.virtualenvs/py3/lib/python3.6/site-packages/soundcard/pulseaudio.py", line 528, in _record_chunk
    readable_bytes = self._pulse._pa_stream_readable_size(self.stream)
AttributeError: '_Recorder' object has no attribute '_pulse'

code:

import soundcard as sc
import wave

lb = sc.all_microphones(include_loopback=True)[0]
rcdr = lb.recorder(44100)

with wave.open('recorded.wav', 'wb') as f:
    f.writeframes(rcdr.record(44100))

I'm on ubuntu 18.04 with pulseaudio 11.1

The recorder is a context manager. You'll have to use it with with.