vedeja
Posts: 2
Joined: Sun Dec 09, 2012 8:46 pm

How to install pyaudio

Sun Dec 09, 2012 8:49 pm

Can someone please bother to describe how pyaudio is installed on the Pi?

User avatar
ZacharyI123
Posts: 263
Joined: Sun Jun 17, 2012 1:09 pm
Location: Ilford, Essex
Contact: Website

Re: How to install pyaudio

Tue Dec 11, 2012 7:26 pm

sudo apt-get install git
git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
Don't be mean, I'm only thirteen 8-)

vedeja
Posts: 2
Joined: Sun Dec 09, 2012 8:46 pm

Re: How to install pyaudio

Wed Dec 12, 2012 10:20 pm

For the record, here's what I did:

$ sudo apt-get install git
$ git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
$ sudo apt-get install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev
$ sudo apt-get python-dev
$ sudo python pyaudio/setup.py install

SpaceGerbil
Posts: 27
Joined: Sat Feb 02, 2013 10:03 am

Re: How to install pyaudio

Fri Mar 15, 2013 12:17 am

$ sudo apt-get install git
$ git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
$ sudo apt-get install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev
$ sudo apt-get python-dev
$ sudo python pyaudio/setup.py install
Many thanks. I wanted this on my laptop as well and had to make a few changes.
In root:
$ sudo apt-get install git
$ sudo git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
$ sudo apt-get install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev
$ sudo apt-get install python-dev
$ cd pyaudio
$ sudo python setup.py install

simple-simon
Posts: 3
Joined: Mon Jul 01, 2013 12:01 pm

Re: How to install pyaudio

Mon Jul 01, 2013 12:05 pm

I have been hacking around and stress that I am no expert being new to Linux and Pi. I found this...

sudo apt-get install python-pyaudio

It seems to install everything required

bohemier
Posts: 1
Joined: Wed Oct 09, 2013 8:36 pm

Re: How to install pyaudio

Wed Oct 09, 2013 8:38 pm

Thanks...
sudo apt-get install python-pyaudio
works like a charm

jim.b
Posts: 1
Joined: Sun Nov 16, 2014 11:14 pm

Re: How to install pyaudio

Sun Nov 16, 2014 11:26 pm

This only appears to setup pyaudio for python2.x. I've tried a few things to get it to work with python3 on my brand new pi and wolfson. Any ideas what I might be missing? I tried: "sudo python3 setup.py install" but still cannot "import pyaudio" in the python3 interpreter. I'm using python 3.2.3. thanks!

DirkS
Posts: 7532
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: How to install pyaudio

Mon Nov 17, 2014 12:29 pm

For python 3

Code: Select all

sudo apt-get install python-dev
needs to be changed to

Code: Select all

sudo apt-get install python3-dev
http://www.raspberrypi.org/forums/viewt ... 32&t=54658 suggests that it can work with python 3

Gr.
Dirk.

smrtsmrf
Posts: 2
Joined: Thu Jun 11, 2015 11:08 pm

Re: How to install pyaudio

Sat Jun 13, 2015 5:56 pm

I've tried these methods, and PyAudio seems to install fine, but then when I try to run the example on the PyAudio documentation site (on my Pi 2), I get slow/choppy/garbled audio which eventually stops. Playing audio with aplay from the command line works just fine, so it must be something with PyAudio.

Does anyone have any help they can offer? I've scoured the web, but can't find any solutions.

Thanks in advance.

zgt
Posts: 3
Joined: Tue Jun 23, 2015 7:18 pm

Re: How to install pyaudio

Tue Jun 23, 2015 7:57 pm

I'm exactly with the same problem, smrtsmrf.

I am using the B+, Python 2.7.3, PyAudio (0.2.8 and 0.2.4) and I also get slow/choppy/garbled audio...
When I play the sound with pygame it works pretty good though. So it should be something with PyAudio...

Did you find what was causing that?

User avatar
jonwitts
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 16
Joined: Fri Oct 17, 2014 3:45 pm
Location: Kingston upon Hull
Contact: Website

Re: How to install pyaudio

Sat Mar 12, 2016 2:06 pm

jim.b wrote:This only appears to setup pyaudio for python2.x. I've tried a few things to get it to work with python3 on my brand new pi and wolfson. Any ideas what I might be missing? I tried: "sudo python3 setup.py install" but still cannot "import pyaudio" in the python3 interpreter. I'm using python 3.2.3. thanks!
To install pyAudio for Python 3 try:

Code: Select all

sudo apt-get install python3-pyaudio 
Just hacking around with it now...

User avatar
jonwitts
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 16
Joined: Fri Oct 17, 2014 3:45 pm
Location: Kingston upon Hull
Contact: Website

Re: How to install pyaudio

Sat Mar 12, 2016 3:14 pm

The following code allows me to record from my USB microphone. It does output a lot of errors first, but it works!

Code: Select all

#!/usr/bin/env python3
import pyaudio
import wave

CHUNK = 512
FORMAT = pyaudio.paInt16 #paInt8
CHANNELS = 1
RATE = 44100 #sample rate
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "pyaudio-output.wav"

p = pyaudio.PyAudio()

stream = p.open(format=FORMAT,
                channels=CHANNELS,
                rate=RATE,
                input=True,
                frames_per_buffer=CHUNK) #buffer

print("* recording")

frames = []

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
    data = stream.read(CHUNK)
    frames.append(data) # 2 bytes(16 bits) per channel

print("* done recording")

stream.stop_stream()
stream.close()
p.terminate()

wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()

Return to “Python”

Who is online

Users browsing this forum: No registered users and 15 guests