Unable to get audio out of 3.5mm jack

Hi All,

I'm sure this is a fairly common issue, however, I am unable to find a solution.
I am trying to create a warning system using node red (raspberry pi) and a two way radio.
I cant get the speakerpi node to work properly. I have installed the ```
sudo apt-get install libasound2-dev


msg : Object
object
_msgid: "03484813242dca83"
speech: "test message"
player: "error"

 Choose Output 
Stream based
 Channel 
Stereo
 Bit Depth 
16 Bit
 Sample Rate (HZ) 
22,050 Hz
 Name

I'm not sure why I am getting this error. I'm thinking its an issue with what im injecting.
Any help would be appreciated.

Thanks,
Mark.

Welcome to the forum Mark!

Did you make sure to set the audio settings (per the readme for the node)?
did you try - outside or NR - to play audio?
what file format did you send to the node?

What version of Node-RED and node.js are you running (take a look at the NR startup log to get this)

I just tried it and it works for me.

Please export your flow and attachet to a reply:

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

Hi Zenofmud,

Thanks for your welcome and quick reply.
I have played audio outside NR (via youtube to the speaker jack).
The audio is fine from YT. So electrically the speakers and circuit are fine.
I did follow the readme and set up the node as suggested but still can't get it to work.

I am sending text to the node to do txt to speech. using a msg.speech string.

I don't have acess to the Raspberry Pi at the moment as it is at work, but I will post the code when I'm in the office next.

Its a new install so I presume its the latest edition of NR however I'm not 100% sure.

are you able to post your working code/demo flow so I can try it on another Raspberry Pi over the weekend ?

Thanks,
Mark

here is the test flow. You will need a wav file to test with

[{"id":"18c51ceca19c7b54","type":"inject","z":"126b675229328575","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":140,"wires":[["59da6b0c65cc40e5"]]},{"id":"59da6b0c65cc40e5","type":"speakerpi-output","z":"126b675229328575","choose":"givenfile","filename":"/home/pi/audio/word1.wav","channels":"1","bitdepth":"16","samplerate":"22050","name":"","x":520,"y":140,"wires":[["663ec6350a63d436"]]},{"id":"663ec6350a63d436","type":"debug","z":"126b675229328575","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":140,"wires":[]},{"id":"651b3627d9e879dc","type":"debug","z":"126b675229328575","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":240,"wires":[]},{"id":"90b852f3e618d295","type":"catch","z":"126b675229328575","name":"","scope":null,"uncaught":false,"x":440,"y":240,"wires":[["651b3627d9e879dc"]]}]

New install of what? The pi OS includes an old version of node-red, so unless you have installed node red (probably using the method suggested in the node red docs) then it will not be up to date.

Its ver 2.2.1 using the instructions from the NR website.

Cheers

Did the test flow I provided work?

Thanks Paul,

No, unfortunately it just output static to the speakers.
When i play the same wav file on vlc via the raspberry pi desktop it works fine.

The debug node indicates that the speakerpi node played the file.

Do you have any suggestions that i could try?

Thanks.

Ok, let me get some basic info
What model Pi? cat /proc/device-tree/model
What OS? lsb_release -c
What version of NR and Node.js (you can get this from the NR startup log) I note you have NR 2.2.1

Raspberry Pi 3 Model B Plus Rev 1.3

Codename: bullseye

19 Feb 11:49:48 - [info] Node-RED version: v2.2.2
19 Feb 11:49:48 - [info] Node.js version: v14.19.0
19 Feb 11:49:48 - [info] Linux 5.10.92-v7+ arm LE

I upgraded to 2.2.2 to see if that would resolve the issue. it didn't make any difference.

thanks,
mark

Open a terminal window and enter amixer and show me the results please.
For reference I get:

Simple mixer control 'Headphone',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback -10239 - 400
  Mono: Playback 31 [97%] [0.31dB] [on]

pi@raspberrypi:~ $ amixer
Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 65500 [100%] [on]
Front Right: Playback 65500 [100%] [on]
Simple mixer control 'Capture',0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 65536
Front Left: Capture 65536 [100%] [on]
Front Right: Capture 65536 [100%] [on]

Hmmm that doesn't look like it is the audio jack - I believe the audio jack it mono.

here is something I found audio - sound output stuck on HDMI (working) - Raspberry Pi Stack Exchange that might help out.

Also what happens if you force audio to the 3.5mm jack - see Raspberry Pi - Configuring Audio Output - YouTube

Audio Rpi
Hi mate,

I only have the headphones as a option.
also, when I play audio from the web browser on the rpi using youtube or vlc, it is fine.
I believe the issue might be something node red or node related as it works fine outside of NR.

When I play my .wav file on vlc, it plays fine. the same .wav file played using the speakerpi node on node red just produces static.

No idea if this will help you or not but this is what I use to play .mp3 on an old Model B

image

IIRC I had to install sudo apt install mpg123

2 Likes

Except it works fine for me, so it is something about your setup vrs mine. One difference is I'm using the 'lite' version - no desktop. I'm going to flash an SD card with the latest and see what happens. Check back in an hour.

1 Like

Thanks, Ill give this a try too.

Ok, it is working for me. Note I did have to issue the command amixer cset numid=3 1 (as explained in the node's README) to hear anything

Raspberry Pi 3 Model B Rev 1.2
bullseye
Node-RED version: v2.2.2
Node.js version: v14.19.0

amixer results
pi@clearpi:~/.node-red $ amixer
Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 1 [0%] [on]
Front Right: Playback 1 [0%] [on]
Simple mixer control 'Capture',0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 65536
Front Left: Capture 65536 [100%] [on]
Front Right: Capture 65536 [100%] [on]

So it's not Node-RED or node-red-contrib-speakerpi node. It could mean that something else you have installed on the Pi is causing the issue...