import speakerphat failing


#1

I have just installed pHat speaker that I got from Pimoroni on my Raspberry B v3 running latest raspbian OS.
When running the test suggested on https://shop.pimoroni.com/products/speaker-phat I get the following error.
I am not a python programmer and need some help please.

testing text-to-speech

testing VU meter
Traceback (most recent call last):
File “/home/pi/Pimoroni/speakerphat/test/test.py”, line 9, in
import speakerphat
ImportError: No module named speakerphat

I have yet to get a peep out of the speaker…

and when I attempt the following it still fails

pi@RPiAIY2:~ $ sudo pip install speakerphat
Collecting speakerphat
Could not find a version that satisfies the requirement speakerphat (from versions: )
No matching distribution found for speakerphat


#2

What do you see if you open a terminal and: ls /home/pi/Pimoroni/speakerphat

The speakerphat module it’s failing to import should be in a python dir next to the test dir.

This line tells it to look in ../python/ for modules, right before import speakerphat whereupon it should find the speakerphat.py here: https://github.com/pimoroni/speaker-phat/tree/master/python

What do you see in your /boot/config.txt file, too?

And if you run:

aplay -L

and

aplay -l


#3

pi@RPiAIY2:~ ls /home/pi/Pimoroni/speakerphat client.conf daemon.conf default.pa python python-backup system.pa test test-backup pi@RPiAIY2:~ less /boot/config.txt
pi@RPiAIY2:~ aplay -L null Discard all samples (playback) or generate zero samples (capture) default Playback/recording through the PulseAudio sound server pivumeter softvol_and_pivumeter sysdefault:CARD=sndrpihifiberry snd_rpi_hifiberry_dac, Default Audio Device dmix:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dac, Direct sample mixing device dsnoop:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dac, Direct sample snooping device hw:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dac, Direct hardware device without any conversions plughw:CARD=sndrpihifiberry,DEV=0 snd_rpi_hifiberry_dac, Hardware device with all software conversions pi@RPiAIY2:~ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
Subdevices: 0/1
Subdevice #0: subdevice #0

and /boot/config.txt contains

For more options and information see

http://rpf.io/configtxt

Some settings may impact device functionality. See link above for details

uncomment if you get no picture on HDMI for a default “safe” mode

#hdmi_safe=1

uncomment this if your display has a black border of unused pixels visible

and your display can output without overscan

#disable_overscan=1

uncomment the following to adjust overscan. Use positive numbers if console

goes off screen, and negative if there is too much border

#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

uncomment to force a console size. By default it will be display’s size minus

overscan.

#framebuffer_width=1280
#framebuffer_height=720

uncomment if hdmi display is not detected and composite is being output

#hdmi_force_hotplug=1

uncomment to force a specific HDMI mode (this will force VGA)

#hdmi_group=1
#hdmi_mode=1

uncomment to force a HDMI mode rather than DVI. This can make audio work in

DMT (computer monitor) modes

#hdmi_drive=2

uncomment to increase signal to HDMI, if you have interference, blanking, or

no display

#config_hdmi_boost=4

uncomment for composite PAL

#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

Uncomment some or all of these to enable the optional hardware interfaces

dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

Uncomment this to enable the lirc-rpi module

#dtoverlay=lirc-rpi

Additional overlays and parameters are documented /boot/overlays/README

Enable audio (loads snd_bcm2835)

#dtparam=audio=on
dtoverlay=i2s-mmap
dtoverlay=hifiberry-dac
start_x=0
enable_uart=1


#4

apparently cut n paste does not work so well. Ill try again.
ls /home/pi/Pimoroni/speakerphat
client.conf daemon.conf default.pa python python-backup system.pa test test-backup

aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default
Playback/recording through the PulseAudio sound server
pivumeter
softvol_and_pivumeter
sysdefault:CARD=sndrpihifiberry
snd_rpi_hifiberry_dac,
Default Audio Device
dmix:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dac,
Direct sample mixing device
dsnoop:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dac,
Direct sample snooping device
hw:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dac,
Direct hardware device without any conversions
plughw:CARD=sndrpihifiberry,DEV=0
snd_rpi_hifiberry_dac,
Hardware device with all software conversions

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
Subdevices: 0/1
Subdevice #0: subdevice #0

I hope that that reads better


#5

Looks like everything is set up correctly from a software perspective.

Do you hear anything if you run:

speaker-test -c2

#6

No sound just lights.
Please see the new message hopefully above where I point out that I have not soldered the 40 pin header just the speaker as I need to get to the GPIO pins.


#7

I’m having a similar issue. Pi zero with speaker phat. Installed all the software and rebooted as per github.com/pimoroni/speaker-phat

Now I get short burst of static noise regularly every few seconds after boot up.

If I run the test script github.com/pimoroni/speaker-phat/blob/master/test/test.py I get

_Traceback (most recent call last):_

_ File “test.py”, line 9, in _
_ import speakerphat_
_ ImportError: No module named speakerphat_

Trying to install gives me:

Could not find a version that satisfies the requirement speakerphat (from versions: )
No matching distribution found for speakerphat

If I run “speaker-test -c2” I get a few seconds of static, then a short pause, then a very short period of static, then:

speaker-test 1.1.3

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 96 to 1048576
Period size range from 32 to 349526
Using max buffer size 1048576
Periods = 4
was set period_size = 262144
was set buffer_size = 1048576
_ 0 - Front Left_
_ 1 - Front Right_
Time per period = 6.535903
_ 0 - Front Left_
Write error: -5,Input/output error
xrun_recovery failed: -5,Input/output error
Transfer failed: Input/output error

No lights show on the front.

I have only wired up the pins specified here: pinout.xyz/pinout/speaker_phat as I too need the GPIO pins for other things.

Any ideas welcome please!

Thank you!


#8

speaker-test -c2 should give exactly as you describe- static. If you use speaker-test -c2 -t wav it will perform a more meaningful test.

In both cases- have you connected all the ground pins (marked with a little dark pip on Pinout) between Speaker pHAT and the Pi?

And what does /etc/asound.conf look like?