diff --git a/workflow/hpr-cn-generate-notes.bash b/workflow/hpr-cn-generate-notes.bash index 8e1ef94..8579196 100755 --- a/workflow/hpr-cn-generate-notes.bash +++ b/workflow/hpr-cn-generate-notes.bash @@ -1,11 +1,17 @@ #!/usr/bin/env bash +# https://brycebeattie.com/files/tts/ +#piper_voice="/opt/bin/piper/piper/piper-voices/en/en_US/lessac/medium/en_US-lessac-medium.onnx" +piper_voice="/opt/bin/piper/piper/piper-voices/en/en_US/kristin/medium/en_US-kristin-medium.onnx" + + + ############################################################################################ # Update db source settings $1 -git_dir="/home/ken/tmp/hpr/hpr_generator" +git_dir="$HOME/tmp/hpr/hpr_generator" if [ ! -d "${git_dir}/.git" ] then #git clone gitea@repo.anhonesthost.net:rho_n/hpr_generator.git "${git_dir}" @@ -21,17 +27,17 @@ cd "${git_dir}" git pull -ssh hpr -t "ls -al /docker/users/hpr/userfiles/sql/hpr.sql;md5sum /docker/users/hpr/userfiles/sql/hpr.sql" -ssh hpr -t "/docker/users/hpr/userfiles/sql/hpr_db_backup.bash" -ssh hpr -t "ls -al /docker/users/hpr/userfiles/sql/hpr.sql;md5sum /docker/users/hpr/userfiles/sql/hpr.sql" - -#/home/ken/tmp/hpr/hpr_generator/utils/update-hpr-db.sh -./utils/update-hpr-db.sh -if [ $? -ne 0 ] -then - echo 'Terminating...' >&2 - exit 1 -fi +# # # # ssh hpr -t "ls -al /docker/users/hpr/userfiles/sql/hpr.sql;md5sum /docker/users/hpr/userfiles/sql/hpr.sql" +# # # # ssh hpr -t "/docker/users/hpr/userfiles/sql/hpr_db_backup.bash" +# # # # ssh hpr -t "ls -al /docker/users/hpr/userfiles/sql/hpr.sql;md5sum /docker/users/hpr/userfiles/sql/hpr.sql" +# # # # +# # # # #$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 hpr_db="${git_dir}/hpr.db" @@ -56,12 +62,7 @@ ORDER BY date DESC LIMIT 1; ") -printf "\n%s\n" "SELECT notes -FROM eps -WHERE duration > 0 -AND series = 47 -ORDER BY date DESC -LIMIT 1;" 1>&2 +# eval $( echo "$row" | @@ -70,10 +71,28 @@ eval $( tr ',' '\n' ) -echo_debug "The last show month was for ${month}, previous_cn_latest_comment: ${latest_comment}, latest_host: ${latest_host}, and previous_cn_latest_episode: ${previous_cn_latest_episode}" - +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 @@ -88,16 +107,10 @@ AND series = 47 ORDER BY date ASC LIMIT 1; ")" -printf "\n%s\n" "SELECT id, date -FROM eps -WHERE duration = 0 -AND series = 47 -ORDER BY date ASC -LIMIT 1;" 1>&2 echo_debug "This is going to be hpr${eps_num} for release on ${eps_date}" -eps_dir="/home/ken/processing/x_${eps_num}_${eps_date}_x" +eps_dir="$HOME/processing/x_${eps_num}_${eps_date}_x" if [ ! -d "${eps_dir}" ] then mkdir -vp "${eps_dir}" @@ -106,32 +119,50 @@ fi echo_debug "The episode dir is \"${eps_dir}\"" shownotes_html="${eps_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="${eps_dir}/Recordings" +comment_script_md="${eps_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 ############################################################################################ # Add New hosts to shownotes results=$(sqlite3 "${hpr_db}" "SELECT hostid, host FROM hosts WHERE hostid > ${latest_host};") -printf "\n%s\n" "SELECT hostid, host FROM hosts WHERE hostid > ${latest_host};" 1>&2 -echo "

New hosts

" > "${shownotes_html}" -echo "

" >> "${shownotes_html}" +echo "

New hosts

" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "

" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" if [ -z "${results}" ] then - echo "There were no new hosts this month." >> "${shownotes_html}" + 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:
" >> "${shownotes_html}" - echo "

" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" fi -echo "

" >> "${shownotes_html}" -echo "" >> "${shownotes_html}" +echo "

" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" ############################################################################################ # Add Last Month's Shows to shownotes @@ -145,49 +176,39 @@ AND eps.valid = 1 AND eps.hostid = hosts.hostid; ") -printf "\n%s\n" "SELECT eps.id, hosts.host, eps.title, eps.date, eps.hostid -FROM eps, hosts -WHERE eps.id > ${previous_cn_latest_episode} -AND eps.date LIKE \"${this_month}%\" -AND eps.valid = 1 -AND eps.hostid = hosts.hostid;" 1>&2 - -echo "

Last Month's Shows

" >> "${shownotes_html}" -echo "" >> "${shownotes_html}" +echo "

Last Month's Shows

" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" # [%# The id 't01' is in the HPR CSS but might give trouble on the IA -%] -echo "" >> "${shownotes_html}" -echo "" >> "${shownotes_html}" -echo "" >> "${shownotes_html}" -echo "" >> "${shownotes_html}" -echo "" >> "${shownotes_html}" -echo "" >> "${shownotes_html}" -echo "" >> "${shownotes_html}" -echo "" >> "${shownotes_html}" +echo "
IdDayDateTitleHost
" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" if [ -z "${results}" ] then echo_error "There were no shows found for this month." else while IFS="→" read -r eps_id host title eps_date hostid do - printf -v hostid "%04d" "${hostid}" - printf -v eps_id "%04d" "${eps_id}" - echo "" >> "${shownotes_html}" - echo "" >> "${shownotes_html}" - echo "" >> "${shownotes_html}" - echo "" >> "${shownotes_html}" - echo "" >> "${shownotes_html}" - echo "" >> "${shownotes_html}" + echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" + echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" + echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" + echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" + echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" + echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" latest_episode=${eps_id} - echo "" >> "${shownotes_html}" + echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" done <<< "${results}" fi -echo "
IdDayDateTitleHost
${eps_id}$( \date --date=${eps_date} +%a )${eps_date}${title}${host}
${eps_id}$( \date --date=${eps_date} +%a )${eps_date}${title}${host}
" >> "${shownotes_html}" -echo "" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" ############################################################################################ # Add Comments to shownotes - function render_comments() { results=${1} @@ -198,39 +219,100 @@ function render_comments() { else this_comment="0" open_line="0" - echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" fi open_line="1" this_comment="${comments_eps_id}" - printf -v hosts_hostid "%04d" "${hosts_hostid}" - printf -v comments_eps_id "%04d" "${comments_eps_id}" - echo "
  • hpr${comments_eps_id} (${eps_date}) \"${eps_title}\" by ${hosts_host}.
  • " >> "${shownotes_html}" - echo "" >> "${shownotes_html}" + echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" + echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" fi } # ------------------------------------------- -echo "

    Comments this month

    " >> "${shownotes_html}" -echo "" >> "${shownotes_html}" +echo "

    Comments this month

    " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" -echo "

    Past shows

    " >> "${shownotes_html}" +echo "

    Past shows

    " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" previous_cn_latest_comment_last_changed=$(sqlite3 "${hpr_db}" "SELECT last_changed FROM comments WHERE comments.id = ${previous_cn_latest_comment};") -printf "\n%s\n" "SELECT last_changed FROM comments WHERE comments.id = ${previous_cn_latest_comment};" 1>&2 results=$(sqlite3 -separator '→' "${hpr_db}" " SELECT @@ -250,28 +332,10 @@ WHERE comments.id > "${previous_cn_latest_comment}" AND eps.id <= "${previous_cn_latest_episode}" ORDER BY eps.date; ") -printf "\n%s\n" " -SELECT - comments.id, - comments.eps_id, - eps.date, - eps.title, - hosts.host, - hosts.hostid, - comments.comment_author_name, - comments.comment_timestamp, - comments.comment_title -FROM comments -JOIN eps ON comments.eps_id = eps.id -JOIN hosts ON eps.hostid = hosts.hostid -WHERE comments.id > "${previous_cn_latest_comment}" - AND eps.id <= "${previous_cn_latest_episode}" -ORDER BY eps.date; -" 1>&2 render_comments "${results}" -echo "

    This month's shows

    " >> "${shownotes_html}" +echo "

    This month's shows

    " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" results=$(sqlite3 -separator '→' "${hpr_db}" " SELECT @@ -290,49 +354,166 @@ JOIN hosts ON eps.hostid = hosts.hostid WHERE eps.date LIKE \"${this_month}-%\" ORDER BY eps.date; ") -printf "\n%s\n" "SELECT - comments.id, - comments.eps_id, - eps.date, - eps.title, - hosts.host, - hosts.hostid, - comments.comment_author_name, - comments.comment_timestamp, - comments.comment_title -FROM comments -JOIN eps ON comments.eps_id = eps.id -JOIN hosts ON eps.hostid = hosts.hostid -WHERE eps.date LIKE \"${this_month}-%\" -ORDER BY eps.date;" 1>&2 render_comments "${results}" ############################################################################################ # Add maillist and cal to shownotes -mailman_link="https://lists.hackerpublicradio.com/pipermail/hpr/$( \date -d"${month}-01 next month" +%Y-%B )/thread.html" -echo "

    Mailing List discussions

    " >> "${shownotes_html}" +mailman_base="https://lists.hackerpublicradio.com/pipermail/hpr/$( \date -d"${this_month}-01" +%Y-%B )" +mailman_link="${mailman_base}/thread.html" +wget "${mailman_link}" -O thread.html + + +grep --perl-regexp -- 'A HREF' thread.html | awk -F '"' '{print $2}' | while read this_post +do + this_post_html="${shownotes_recordings_dir}/Post${this_post%.*}.html" + if [ ! -e ${this_post_html} ] + then + wget ${mailman_base}/${this_post} --output-document=${this_post_html} + fi + + this_post_txt="${shownotes_recordings_dir}/Post${this_post%.*}.txt" + if [ ! -e ${this_post_txt} ] + then + echo "# Post${this_post%.*}vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv" > "${this_post_txt}" + grep ' ' "${this_post_html}" | tee --append "${this_post_txt}" + sed --quiet --expression='//,//{ //d; //d; p; }' "${this_post_html}" | tee --append "${this_post_txt}" + sed -e 's#^ ##g' -e 's## says:#g' -e 's#
    ##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 -n "${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 + echo " " >> ${comment_script_md} + cat ${this_post} >> ${comment_script_md} + + 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" + + + 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 "

    Mailing List discussions

    " | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" 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} +${mailman_link}" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" -

    Events Calendar

    +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" + +echo "

    Events Calendar

    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.
    " >> "${shownotes_html}" +page." | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" latest_comment=$(sqlite3 "${hpr_db}" "SELECT MAX(id) FROM comments;") -printf "\n%s\n" "" 1>&2 -echo "" >> "${shownotes_html}" +echo "" | tee --append "${shownotes_html_edited}" >> "${shownotes_html}" -cp -v "${shownotes_html}" "${shownotes_html%.*}"_edited.html -ls -al "${eps_dir}" +cd "${eps_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 + +# # # for audio_wav in "${shownotes_recordings_dir}"/*.wav +# # # do +# # # if [ ! -e "${audio_wav%.*}.mp3" ] +# # # then +# # # ffmpeg -i "${audio_wav}" "${audio_wav%.*}.mp3" +# # # fi +# # # done +# # # +# # # diff --git a/workflow/hpr-process_episode.bash b/workflow/hpr-process_episode.bash index f87073d..7b772d9 100755 --- a/workflow/hpr-process_episode.bash +++ b/workflow/hpr-process_episode.bash @@ -18,7 +18,9 @@ outro_flac="${processing_dir}/outro.flac" # The outro edited media outro_srt="${processing_dir}/outro.srt" # The outro subtitle file intro_srt="${processing_dir}/intro.srt" # The intro subtitle template file -piper_voice="/opt/bin/piper/piper/piper-voices/en/en_US/lessac/medium/en_US-lessac-medium.onnx" +# https://brycebeattie.com/files/tts/ +#piper_voice="/opt/bin/piper/piper/piper-voices/en/en_US/lessac/medium/en_US-lessac-medium.onnx" +piper_voice="/opt/bin/piper/piper/piper-voices/en/en_US/kristin/medium/en_US-kristin-medium.onnx" working_dir_bypass="false" skip_post_show="false"