I am setting up the BLF warning system Tyler documented, but my NOAA station is not available online. I might have put it online, but noaaweatherradio.org forces https (don’t get me started) for new users, and it looks like come December all the http feeds go away, which is what is needed for music on hold. So I did my own local solution, with the added advantage of only three seconds delay.
Out of my junk box (more correctly termed my junk basement) came an old Pi B+, an RTL-SDR dongle, and an old HT antenna. With a new installation of Raspian on my sd card, after updating and doing the rest of the new Pi setup, I then loaded a few bits of software
apt-get install rtl-sdr ezstream icecast2 lame
During install ezstream asked for passwords, I used xyzzy for all three, no worries about security on this machine.
I created a config file for ezstream called kwwx.xml, for Key West Weather
http://localhost:8000/WXJ95.mp3
xyzzy
MP3
stdin
1
WXJ95 from Key West
https://localhost
Public Information
NOAA Radio from Key West
64
1
44100
0
Then you are ready to start the whole mess piped together
rtl_fm -f 162.400m -E deemp -M fm - | lame -r -s 24 --scale 2.0 -m m -b 24 --cbr - - | ezstream -c /etc/kwwx.xml
I stuck that into crontab as @reboot, and it works from a cold start. So far it has stayed up, but I may write a script to restart it in case it dies.
rt_fm is the sdr code to pluck out an FM signal, 162.4 is obviously my NOAA frequency.
I added -E deemp to the rtl-fm call to lower the high end, making it sound much better.
lame transcodes the raw audio into an mp3. It took a little tweaking to find numbers that worked, if your system is different you may need to tweak to get natural speed audio. You will know if you need this. You can adjust the volume with the --scale parameter.
ezstream creates a web server from the incoming mp3 stream
When I go to http://10.0.0.34:8000 there is a web interface, at http://10.0.0.34:8000/WXJ95.mp3 I get the stream alone, I simply point the MoH configuration there.
This setup can get any narrow FM signal into a stream and therefore on the phone. But it also works for FM broadcast with a little tweaking, this puts a local station on the stream:
rtl_fm -f 99.500m -M wbfm - | lame -r -s 32 -m m -b 64 --cbr - - | ezstream -c /etc/kwwx.xml
The audio quality isn’t great on broadcast stations, perhaps it is a transcoding problem, something for others to tweak. I’m surprised this isn’t a commonly advertised way for the general asterisk community to get MoH, the solutions I’ve found are much more involved.
This uses about half the CPU of the very slow single core B+ (60% for wideband FM), so I may try to add it to my PBX which runs on a pi 4.
Addendum: it turns out raspbx has an old version of ezstream, 0.5.6. since them ezstream has changed their file syntax, if you have version 1.0 or higher (check with "ezstream -V") this config is reported to work by AG7SU:
127.0.0.1
xyzzy
/WXJ95.mp3
MP3
stdin
```