UPDATED: Create Your Own Radio Station myDIYfm
In this article I will describe a powerful new feature and updates to the myDIYfm radio station built using a Raspberry Pi 3 micro computer. If you missed the original article you can find it here. Please note the same disclaimer used in that original article applies to this one as well, and is incorporated by reference. Also note the original article is still 100% valid and usable.
So What is This New Feature?
I have added the ability to add audio content from Youtube videos using the youtube-dl python library. I have automated this to a significant degree while giving you full control over the content. However, doing this on the Raspberry Pi 3 is not a fast process. The majority of the time it takes to work this magic is not spent in the video downloads, but rather in the extraction of the audio into an MP3 file.
Another aspect affecting performance is that the titles of the downloaded videos are also converted to .wav audio using a TTS (Text To Speech) engine. I was not happy with the quality of Festival voices, and I was unsuccessful in adding new ones on the Pi platform. I have successfully added Mimic, a leaner faster TTS engine, which has far more and better quality voices that can be switched "on the fly", which are used announce the titles of youtube audios in a female voice, in contrast to the male voice for all other TTS uses.
These "title .wavs" are queued just ahead of the video's audio track, to announce each item. The choice of TTS engine (Festival or Mimic) can be selected at setup time. Total setup time is now around 5 hours long for all compilation and downloads.
To facilitate programming these videos into the broadcast schedule, changes were required to the schedule file format. I have added 2 new network op codes (RNDM and FLDR) to schedule playback of this new content. Placing RNDM in the NETWORK field will announce and play the content in a random order, and the FLDR op code will play them in order based on alphabetic sorting of the title. The actual content is located in the folder indicated by the FILE / URL field of the schedule item.
How Does the Downloading Work?
A new python program, dlYTaudio.py, was created to manage all aspects of downloading, including video selection criteria, conversion to MP3 audio and title announcement generation. The Youtube video URLs may include individual videos, entire playlists or a mixture of both. It also uses qualifiers to select the videos based on various criteria, among them are:
- upload author
- playback time
- keywords in the title
- size of the destination folder
- maximum number of videos to save
The dlYTaudio.py program requires ffmpeg and other software which must be compiled from source code to produce an executable program that runs on the Raspberry Pi. New installers (setup2.bash and setup4Youtube bash shell scripts) are provided to get up and running starting with a base level, freshly installed Raspberry Pi. Refer to the previous article on how to install the Raspbian OS with NOOBs.
Once the base operating system is installed you will use the following commands to download and run the setup2.bash script which will take care of the rest of the installation:
curl -s https://pastebin.com/raw/f2QGcbSw | tr -d '\r' > setup2.bash
chmod 755 setup2.bash
./setup2.bash
The installation process will take some time to complete, much longer if you choose to include the required support for Youtube downloads. You will be asked if you want to do that near the end of the main installation. If you answer "n" the installation will conclude asking you to enter a password for the mydiyfm account and present you with the README.txt.
If you decide later to add support for Youtube, you may do so by running these commands in the mydiyfm folder (as root):
curl -s https://pastebin.com/raw/HRzmKawY | tr -d '\r' > setup4Youtube
chmod 755 setup4Youtube
./setup4Youtube
Be aware it will take several hours to run the setup4Youtube script, which includes downloading and compiling code, downloading and processing approximately 50 Youtube videos and a sample schedule that uses them. You can expect it to take 2 hours or so to complete, but no interaction is required, so you could start it and then go do other things.
I decided not to try to create an update process to the original mydiyfm but rather preserve it so as not to invalidate it. If you want to upgrade but preserve your schedule the main difference is removing the END TIME field, which is easily done with a text editor using a global find and replace, searching for " 0000 " and deleting every instance. You will also need to update the TTS op codes in the NETWORK field to FTS, as TTS is now unused. FTS is "File" Text to Speech.
There are a few minor bugs in the original setup.bash installer (the mydiyfm account wasn't added to the audio group, and the info on adding tmux to the .profile required a change) that were corrected, and I have also fixed the automatic GCN Live "flow" compensation, which detects dead air on GCN streams and switches the stream URL to an alternate. It doesn't change very often, but when it does you'll have dead air for GCN programs until you update the schedule. That shouldn't be necessary now. FPP Radio News source is no longer being updated, so you will have to replace those lines in your schedule as well.
I have been thinking about how to provide a complete image of mydiyfm in the form of an archive (such as a zip or tar file) that could be applied to a base Raspbian OS image installed with NOOBs. After a full installation including the sample Youtube videos, 19GB remains available out of 32GB. The mydiyfm folder comes in at around 750MB.
Another option would be to create a complete SD-Card image that includes EVERYTHING. I have not found a good platform for either that allows a truly uncensorable, "pirate" experience to preserve the work. Perhaps an IPFS or blockchain solution will emerge. Stay alert and vigilant, as only time will tell. It may appear earlier than you think!
Congratulations @pirate-parties! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
Congratulations @pirate-parties! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!