#!/usr/bin/env bash # https://brycebeattie.com/files/tts/ # # https://github.com/OHF-Voice/piper1-gpl # A fast and local neural text-to-speech engine that embeds espeak-ng for phonemization. # GPL-3.0 license # # https://github.com/espeak-ng/espeak-ng # The eSpeak NG is a compact open source software text-to-speech synthesizer for Linux, Windows, Android and other operating systems. # It supports more than 100 languages and accents. It is based on the eSpeak engine created by Jonathan Duddington. # Licenses GPL-3.0, Apache-2.0, BSD-2-Clause # # LJSpeech (high) US English female voice. Single speaker. # Trained from scratch for 2000 epochs on high quality settings using the LJ Speech dataset. # I reencoded the recordings to a bit rate of 22050 Hz so it would match other voices released for Piper TTS. # License: public domain # # https://keithito.com/LJ-Speech-Dataset/ # This is a public domain speech dataset consisting of 13,100 short audio clips of a single speaker reading passages from 7 non-fiction books. # A transcription is provided for each clip. Clips vary in length from 1 to 10 seconds and have a total length of approximately 24 hours. # The texts were published between 1884 and 1964, and are in the public domain. # The audio was recorded in 2016-17 by the LibriVox project and is also in the public domain. # piper_voice="/opt/bin/piper/piper/piper-voices/en/en_US/ljspeech/high/en_US-ljspeech-high.onnx" function post_show_to_hpr_db() { echo_debug "Retrieving information for hpr${ep_num} for release on ${ep_date}" IFS='→' read -r ep_num ep_date title duration summary hostid series_id explicit license tags <<< "$( sqlite3 -separator '→' "${hpr_db}" "SELECT id, date, title, duration, summary, hostid, series, explicit, license, tags FROM eps WHERE eps.id = \"${ep_num}\" AND date = \"${ep_date}\" LIMIT 1;" )" echo_debug "Posting the show to the HPR DB. post_show_to_hpr_db()" if [ ! -s "${shownotes_html_edited}" ] then echo_error "Failed to find the extracted shownote html file \"${shownotes_html_edited}\"" fi notes="$( cat "${shownotes_html_edited}" | jq --slurp --raw-input @uri | sed -e 's/%0A"$//g' -e 's/^"//g' )" title_encoded="$( echo "${title}" | jq --slurp --raw-input @uri | sed -e 's/%0A"$//g' -e 's/^"//g' )" summary_encoded="$( echo "${summary}" | jq --slurp --raw-input @uri | sed -e 's/%0A"$//g' -e 's/^"//g' )" post_show_json="${working_dir}/post_show.json" echo "{ \"ep_num\": \"${ep_num}\", \"ep_date\": \"${ep_date}\", \"title\": \"${title_encoded}\", \"duration\": \"${duration}\", \"summary\": \"${summary_encoded}\", \"hostid\": \"${hostid}\", \"series_id\": \"${series_id}\", \"explicit\": \"${explicit}\", \"episode_license\": \"${license}\", \"tags\": \"${tags}\", \"notes\": \"${notes}\" }" > "${post_show_json}" if [ $? -ne 0 ] then echo_error "The file \"${post_show_json}\" is not valid json." fi jq 'del(.notes)' post_show.json curl --netrc --show-headers --request POST "https://hub.hackerpublicradio.org/cms/update_show_json.php" --header "Content-Type: application/json" --data-binary "@${post_show_json}" } ############################################################################################ # Update db source settings $1 git_dir="$HOME/tmp/hpr/hpr_generator" hpr_db="${git_dir}/hpr.db" hpr_sql="${git_dir}/hpr.sql" if [ ! -d "${git_dir}/.git" ] then #git clone gitea@repo.anhonesthost.net:rho_n/hpr_generator.git "${git_dir}" git clone gitea@repo.anhonesthost.net:HPR/hpr_generator.git "${git_dir}" fi if [ ! -d "${git_dir}" ] then echo_error "The git dir \"${git_dir}\" is missing" fi cd "${git_dir}" git pull ssh hpr -t "/docker/users/hpr/userfiles/sql/hpr_db_backup.bash" remote_hpr_sql_md5sum="$( ssh hpr -t "md5sum /docker/users/hpr/userfiles/sql/hpr.sql" 2>&1 | grep /docker/users/hpr/userfiles/sql/hpr.sql | awk '{print $1}' )" hpr_sql_md5sum="$( md5sum "${hpr_sql}" | awk '{print $1}' )" if [ "${remote_hpr_sql_md5sum}" != "${hpr_sql_md5sum}" ] then echo_debug "The hpr.sql file changed, downloading new version" #$HOME/tmp/hpr/hpr_generator/utils/update-hpr-db.sh ./utils/update-hpr-db.sh if [ $? -ne 0 ] then echo 'Terminating...' >&2 exit 1 fi fi if [[ ! -s "${hpr_db}" || -z "${hpr_db}" ]] then echo_error "The \"hpr_db\" variable/file is missing." fi if [ "$( file --brief --mime-type "${hpr_db}" | grep --count 'application/vnd.sqlite3' )" -ne "1" ] then echo_error "The \"hpr_db\" variable has not a valid \"application/vnd.sqlite3\" mime type." fi ############################################################################################ # Get previous show info row=$(sqlite3 "${hpr_db}" " SELECT notes FROM eps WHERE duration > 0 AND series = 47 ORDER BY date DESC LIMIT 1; ") # eval $( echo "$row" | grep -o '' | sed -E 's//\1/' | tr ',' '\n' ) previous_month="${month}" this_month="$( \date --date "${previous_month}-01 + 1 month" "+%Y-%m" )" previous_cn_latest_comment="${latest_comment}" previous_cn_latest_episode="${latest_episode}" previous_latest_host="${latest_host}" end_of_month_episode_date="$( \date --date "${this_month}-01 + 1 month - 1 day" "+%Y-%m-%d" )" echo_debug "The last show month was for ${previous_month}, and this month is ${this_month}, previous_cn_latest_comment: ${previous_cn_latest_comment}, latest_host: ${previous_latest_host}, and previous_cn_latest_episode: ${previous_cn_latest_episode}, end_of_month_episode_date: ${end_of_month_episode_date}" ############################################################################################ # Get last show info IFS='|' read -r end_of_month_episode_number <<< "$(sqlite3 "${hpr_db}" " SELECT MAX(id) AS end_of_month_episode_number FROM eps WHERE date <= \"${end_of_month_episode_date}\" LIMIT 1; ")" echo_debug "Last episode this month is hpr${end_of_month_episode_number} released on ${end_of_month_episode_date}" ############################################################################################ # Get next show info this_month=$( \date --date="${month}-01 +1 month" +%Y-%m ) IFS='|' read -r ep_num ep_date <<< "$(sqlite3 "${hpr_db}" " SELECT id, date FROM eps WHERE duration = 0 AND series = 47 ORDER BY date ASC LIMIT 1; ")" echo_debug "This is going to be hpr${ep_num} for release on ${ep_date}" working_dir="$HOME/processing/x_${ep_num}_${ep_date}_x" if [ ! -d "${working_dir}" ] then mkdir -vp "${working_dir}" fi echo_debug "The episode dir is \"${working_dir}\"" shownotes_html="${working_dir}/shownotes.html" if [ -e "${shownotes_html}" ] then rm -v "${shownotes_html}" fi shownotes_html_edited="${shownotes_html%.*}"_edited.html if [ -e "${shownotes_html_edited}" ] then rm -v "${shownotes_html_edited}" fi shownotes_recordings_dir="${working_dir}/Recordings" comment_script_md="${working_dir}/script.md" if [ -e "${comment_script_md}" ] then rm -v "${comment_script_md}" fi if [ ! -d "${shownotes_recordings_dir}" ] then mkdir -vp "${shownotes_recordings_dir}" fi ############################################################################################ # Call to action echo "
We would love it if you could assist with the recording of comments for this episode.
Selecting solocast record will allow you to record a comment or post, which syncthing will syncronise to the rest of the team.
" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" ############################################################################################ # Add New hosts to shownotes results=$(sqlite3 "${hpr_db}" "SELECT hostid, host FROM hosts WHERE hostid > ${latest_host};") echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}"
if [ -z "${results}" ]
then
echo "There were no new hosts this month." | tee --append "${shownotes_html_edited}" >> "${shownotes_html}"
newest_host="${latest_host}"
else
echo "Welcome to our new hosts:
" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}"
echo "
| Id | " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" echo "Day | " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" echo "Date | " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" echo "Title | " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" echo "Host | " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" echo "
|---|---|---|---|---|
| ${eps_id} | " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" echo "$( \date --date=${this_ep_date} +%a ) | " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" echo "${this_ep_date} | " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" echo "${title} | " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" echo "${host} | " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" latest_episode=${eps_id} echo "
##g' -e 's###g' -i "${this_post_txt}" fi done for this_post in ${shownotes_recordings_dir}/Post*txt do this_post_name="$( basename "${this_post}" )" if [ "$( find ${shownotes_recordings_dir} -type f -iname "${this_post_name%.*}*.wav" | wc -l )" -eq "0" ] then kate "${this_post}" >/dev/null 2>&1 & fi done if [ "$( ps -ef | grep kate | grep Post | wc -l )" -ne "0" ] then read -p "Were the posts edited ? (N|y) ? " -n 1 -r echo # (optional) move to a new line if [[ ! $REPLY =~ ^[yY]$ ]] then echo_error "The final review was not approved." fi fi for this_post in ${shownotes_recordings_dir}/Post*txt do post_id="$( basename "${this_post%.*}" )" post_script_txt="${shownotes_recordings_dir}/${post_id}.txt" post_script_piper="${shownotes_recordings_dir}/${post_id}_piper.wav" post_script_espeak="${shownotes_recordings_dir}/${post_id}_espeak.wav" echo " " >> ${comment_script_md} echo "# ${post_id%.*}vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv" >> ${comment_script_md} cat ${this_post} >> ${comment_script_md} if [ ! -e "${post_script_piper}" ] then echo_debug "Genereating piper \"${post_script_piper}\"" piper --model "${piper_voice}" --input-file "${post_script_txt}" --output_file "${post_script_piper}" fi if [ ! -e "${post_script_espeak}" ] then echo_debug "Genereating espeak \"${post_script_espeak}\"" espeak -f "${post_script_txt}" -w "${post_script_espeak}" fi done echo "
Policy decisions surrounding HPR are taken by the community as a whole. This discussion takes place on the Mailing List which is open to all HPR listeners and contributors. The discussions are open and available on the HPR server under Mailman.
The threaded discussions this month can be found here:
${mailman_link}" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" echo "With the kind permission of LWN.net we are linking to The LWN.net Community Calendar.
Quoting the site:
This is the LWN.net community event calendar, where we track events of interest to people using and developing Linux and free software. Clicking on individual events will take you to the appropriate web page." | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" latest_comment=$(sqlite3 "${hpr_db}" "SELECT MAX(id) FROM comments;") echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" cd "${working_dir}" while [ "$( $HOME/sourcecode/hpr/solocast/solocast/solocast.py status | grep --count 'All Segments Recorded' )" == "0" ] do $HOME/sourcecode/hpr/solocast/solocast/solocast.py record $HOME/sourcecode/hpr/solocast/solocast/solocast.py status sleep 1 done rsync -av --partial --progress ${working_dir}/Recordings/ hpr:hackerpublicradio.org/public_html/eps/hpr${ep_num}/Recordings/ rsync -av --partial --progress ${working_dir}/script.md hpr:hackerpublicradio.org/public_html/eps/hpr${ep_num}/script.md post_show_to_hpr_db echo_debug "The End."