From 5bf4ab50e13a9be2923ddebe69525b40df8ab3bc Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Sat, 5 Nov 2022 08:02:44 -0400 Subject: Separate caption and prerec roles --- roles/prerec/tasks/main.yml | 28 ++++++++++++++++++++++++++++ roles/prerec/templates/process-prerec.sh | 18 ++++++++++++++++++ roles/prerec/templates/run-aeneas.sh | 14 ++++++++++++++ roles/prerec/templates/update-task-status.sh | 10 ++++++++++ roles/prerec/templates/upload.sh | 6 ++++++ 5 files changed, 76 insertions(+) create mode 100644 roles/prerec/tasks/main.yml create mode 100755 roles/prerec/templates/process-prerec.sh create mode 100755 roles/prerec/templates/run-aeneas.sh create mode 100755 roles/prerec/templates/update-task-status.sh create mode 100755 roles/prerec/templates/upload.sh (limited to 'roles/prerec') diff --git a/roles/prerec/tasks/main.yml b/roles/prerec/tasks/main.yml new file mode 100644 index 0000000..5241531 --- /dev/null +++ b/roles/prerec/tasks/main.yml @@ -0,0 +1,28 @@ +- name: Ensure the directory exists + file: + path: "{{ emacsconf_caption_dir }}/scripts" + state: directory + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" +- name: Recreate encoding script only if it's not there + tags: process-prerec + template: + src: "reencode.sh" + dest: "{{ emacsconf_caption_dir }}/scripts/reencode.sh" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" + # This avoids overwriting zaeph's + force: no + mode: 0775 +- name: Copy scripts for processing + tags: process-prerec + template: + src: "{{ item }}" + dest: "{{ emacsconf_caption_dir }}/scripts/{{ item }}" + owner: "{{ emacsconf_user }}" + group: "{{ emacsconf_group }}" + mode: 0775 + loop: + - process-prerec.sh + - update-task-status.sh + - upload.sh diff --git a/roles/prerec/templates/process-prerec.sh b/roles/prerec/templates/process-prerec.sh new file mode 100755 index 0000000..e49aa72 --- /dev/null +++ b/roles/prerec/templates/process-prerec.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# {{ ansible_managed }} + +ORIGINAL=$1 +REENCODED=$(echo "$ORIGINAL" | perl -pe 's/^(emacsconf-[0-9]*-.*?--.*?--.*?--).*/$1reencoded.webm/') +SLUG=$(echo "$ORIGINAL" | perl -ne '/^emacsconf-[0-9]*-(.*?)--/ && print $1') +MAIN=$(echo "$ORIGINAL" | perl -pe 's/^(emacsconf-[0-9]*-.*?--.*?--.*?--).*/$1main.webm/') +SCREEN=reencode-$SLUG +if ! ( screen -ls | grep -q $SLUG ); then + screen -dmS $SCREEN +fi +( cd /data/emacsconf/cache; ./update-cache ) +/data/emacsconf/2022/scripts/update-task-status.sh $SLUG "WAITING_FOR_PREREC" "PROCESSING" +#if [[ ! -f "$REENCODED" ]]; then +screen -S $SCREEN -X screen -t reencode-$SLUG /bin/bash -c "/data/emacsconf/2022/scripts/reencode.sh \"$ORIGINAL\" \"$REENCODED\" && /data/emacsconf/2022/scripts/upload.sh $REENCODED && exec /bin/bash" & +#fi +screen -S $SCREEN -X screen -t captions-$SLUG /bin/bash -c "/data/emacsconf/2022/scripts/process-captions.py $(dirname $ORIGINAL); /data/emacsconf/2022/scripts/update-task-status.sh $SLUG PROCESSING TO_ASSIGN; exec /bin/bash" +screen -x $SCREEN diff --git a/roles/prerec/templates/run-aeneas.sh b/roles/prerec/templates/run-aeneas.sh new file mode 100755 index 0000000..6f40134 --- /dev/null +++ b/roles/prerec/templates/run-aeneas.sh @@ -0,0 +1,14 @@ +#!/usr/bin/bash +# +# {{ ansible_managed }} +# +AUDIO=$(ls *.opus *.ogg | head -n1) +BASE=$(echo $AUDIO | perl -pe 's/^(emacsconf-2022-.*?--.*?--.*?)--.*/$1/') +echo $AUDIO +echo $BASE +if [ ! -f $BASE--whisper.vtt ]; then + cp ${BASE}--main.vtt ${BASE}--whisper.vtt +fi +python3 -m aeneas.tools.execute_task $AUDIO *.txt "task_language=eng|os_task_file_format=vtt|is_text_type=plain" ${BASE}--aeneas.vtt +cp ${BASE}--aeneas.vtt ${BASE}--main.vtt +/data/emacsconf/2022/scripts/upload.sh ${BASE}--main.vtt diff --git a/roles/prerec/templates/update-task-status.sh b/roles/prerec/templates/update-task-status.sh new file mode 100755 index 0000000..18b7c1b --- /dev/null +++ b/roles/prerec/templates/update-task-status.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# {{ ansible_managed }} +SLUG="$1" +FROM_STATUS="$2" +TO_STATUS="$3" +cd ~/emacsconf-2022-private +git pull +emacsclient --eval "(progn (emacsconf-update-talk-status \"$SLUG\" \"$FROM_STATUS\" \"$TO_STATUS\") (emacsconf-with-talk-heading \"$SLUG\" (emacsconf-cache-video-data (emacsconf-get-talk-info-for-subtree)) (save-buffer)))" +git commit -m "Update task status for $SLUG" conf.org +git push diff --git a/roles/prerec/templates/upload.sh b/roles/prerec/templates/upload.sh new file mode 100755 index 0000000..f723d29 --- /dev/null +++ b/roles/prerec/templates/upload.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# {{ ansible_managed }} + +scp $* orga@media.emacsconf.org:~/backstage +emacsclient --eval "(emacsconf-publish-backstage-index)" +rsync -avze ssh orga@media.emacsconf.org:~/backstage/ /data/emacsconf/cache/ -- cgit v1.2.3