updating editing routine

main
Christos Angelopoulos 2022-03-22 23:08:56 +02:00
parent 06d6812bff
commit 5607f20f60
2 changed files with 97 additions and 40 deletions

91
Sapo.sh
View File

@ -26,27 +26,19 @@ echo "NAME : ""$NAME"
mkdir "$DIRECTORY""Sapo_""$NAME"/
##text delimitation to setences
echo $(cat "$FILE")>"$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # get rid of new lines
##sapofonetix: abbreviation, mispronunciation & alphabet substitutions
sed "s/—/\,\n/g;
s/^ *//g;
s/^\;$//g;
s/^\.$//g;
s/^'//g;
s/\…/\,/g;
s/\/\'/g;
s/(/\,\n(/g;
s/)/),\n/g;
s/[\.\!\?\:\;]/\.\n/g;
s/\.\.\./\.\n/g" "$FILE" >"$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt
sed -i "/^$/d" "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt #get rid of empty lines
sed -i -f $HOME/git/sapo/sapofonetix.sed "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt
#done < "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt
sed -i 's/\.\.\./\.\n/g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # get rid of ...
sed -i "s/\/\'/g" "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # get rid of
sed -i 's/[\.\!\?\:\;]/\.\n/g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # delimit to .
sed -i 's/\…/\,/g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # get rid of …
sed -i 's///g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # get rid of
sed -i 's/(/\,(/g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # delimit to (
sed -i 's/)/),/g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # delimit to )
sed -i 's/^ *//g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # delete space at beginning of line
sed -i 's/^\;$//g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # get rid of just ; lines
sed -i 's/^\.$//g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # get rid of just . lines
sed -i "s/^'//g" "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt #get rid of ' at start of line
sed -i 's/^Ey /A /g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # A's at line start are usually articles, not capitals
#sed -i 's/\,/\n/3' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # delimit to 3rd occurence of ,
#sed -i "s/—/ — /g" "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # put spaces around —, to not interfere with pronunciation
sed -i "s/—/\,/g" "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # convert — to ,
##################extra delimit to comma and space ###################################
DELIM=$(cat "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|wc -l)
while [ $DELIM -ge 1 ]
@ -82,7 +74,9 @@ do
echo "Task completed for line "$DELIM
((DELIM--))
done
####################### substitute Ey =>A and Eye=>I at beggining of line
sed -i "s/^ *\<Ey\>/A/g;s/^ *\<Eye\>/I/g" "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt
########################################
yad --image "$HOME/git/sapo/sapo.png" --height=40 --width=400 --title="${NAME} - Sapo" --button=gtk-cancel:1 --button=gtk-open:2 --button=gtk-ok:0 --text="The text is prepared, Press:
1. <span foreground='yellow'><b>Open </b></span>to edit the new file
2. <span foreground='yellow'><b>OK </b></span>to proceed to speech conversion." --window-icon=$HOME/git/sapo/sapo.png
@ -185,21 +179,52 @@ done
--window-icon=$HOME/git/sapo/sapo.png \
--image "$HOME/git/sapo/sapo_progress.png" \
--auto-close
####### FIXING ERRORS ONE BY ONE ############
TOTAL_ERRORS=$(cat "$DIRECTORY""Sapo_""$NAME"/errors.tsv|wc -l)
####### FIXING ERRORS ONE BY ONE or EDIT THE FILE LINE BY LINE############
yad --image "$HOME/git/sapo/sapo-fix.png" \
--height=40 --width=200 --title="${NAME} - Sapo" \
--text="Which lines do you want to fix?" \
--button=gtk-cancel:1 \
--button='All Lines':2 \
--button='Just Errors':3 \
--window-icon=$HOME/git/sapo/sapo-fix.png
case $? in
1) exit
;;
2) LINES_TO_EDIT="ALL"
;;
3) LINES_TO_EDIT="ERRORS"
;;
esac
if [[ $LINES_TO_EDIT == "ALL" ]]
then
TOTAL_ERRORS=$(cat "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|wc -l)
else
TOTAL_ERRORS=$(cat "$DIRECTORY""Sapo_""$NAME"/errors.tsv|wc -l)
fi
ERROR_LINE=1
while [ $ERROR_LINE -le $TOTAL_ERRORS ]
do
CURRENT_ERROR_LINE=$(cat "$DIRECTORY""Sapo_""$NAME"/errors.tsv|head -$ERROR_LINE|tail +$ERROR_LINE)
ERROR_TEXT_LINE=$(echo $CURRENT_ERROR_LINE|awk '{print $1}')
ERROR_WAV=$(echo $CURRENT_ERROR_LINE|awk '{print $2}')
if [[ $LINES_TO_EDIT == "ALL" ]]
then
CURRENT_ERROR_LINE=$ERROR_LINE
ERROR_TEXT_LINE=$ERROR_LINE
else
CURRENT_ERROR_LINE=$(cat "$DIRECTORY""Sapo_""$NAME"/errors.tsv|head -$ERROR_LINE|tail +$ERROR_LINE)
ERROR_TEXT_LINE=$(echo $CURRENT_ERROR_LINE|awk '{print $1}')
fi
ERROR_WAV="$(printf "%.6d" $ERROR_TEXT_LINE)".wav
TEXT_TO_CORRECT="$(cat "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|head -$ERROR_TEXT_LINE|tail +$ERROR_TEXT_LINE)"
GO=false
while [[ $GO == false ]]
do
yad --image "$HOME/git/sapo/sapo.png" \
--title="Line $ERROR_TEXT_LINE - $NAME" \
--height=40 --width=400 \
--title="Line $ERROR_TEXT_LINE ( of $TOTAL_ERRORS )- $NAME" \
--button=gtk-cancel:1 \
--button='▶️ Play Audio':2 \
--button='🔃 Re-Render':3 \
@ -207,19 +232,18 @@ do
--button='🗡 Split-Render':5 \
--button='🎵 Edit audio':7 \
--button='❌ Remove audio':6 \
--button='😃 Keep/Next':0 \
--text="Text of line $ERROR_TEXT_LINE :
--button='⬅️ Previous Line':8 \
--button='➡️ Next Line':0 \
--text="Text of line $ERROR_TEXT_LINE ( of $TOTAL_ERRORS ):
<span foreground='yellow'><b>$TEXT_TO_CORRECT</b></span>
<i>What would you like to do?</i>" \
-What would you like to do?" \
--window-icon=$HOME/git/sapo/sapo.png
case $? in
0) GO=true
;;
1) GO=true;exit
1) exit
;;
2) if [[ -e "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV ]];then celluloid "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV & else notify-send "There is no file ""$DIRECTORY""Sapo_""$NAME"/"$ERROR_WAV"".";fi
;;
@ -234,6 +258,7 @@ do
;;
7)audacity "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
;;
8) GO=true; ERROR_LINE=$(($ERROR_LINE - 2))
esac
done
((ERROR_LINE++))

View File

@ -21,14 +21,44 @@ case $? in
esac
DIRECTORY=${FILE%/*}/
NAME=${FILE##*/}
####### FIXING ERRORS ONE BY ONE ############
TOTAL_ERRORS=$(cat "$DIRECTORY""Sapo_""$NAME"/errors.tsv|wc -l)
####### FIXING ERRORS ONE BY ONE or EDIT THE FILE LINE BY LINE############
yad --image "$HOME/git/sapo/sapo-fix.png" \
--height=40 --width=200 --title="${NAME} - Sapo" \
--text="Which lines do you want to fix?" \
--button=gtk-cancel:1 \
--button='All Lines':2 \
--button='Just Errors':3 \
--window-icon=$HOME/git/sapo/sapo-fix.png
case $? in
1) exit
;;
2) LINES_TO_EDIT="ALL"
;;
3) LINES_TO_EDIT="ERRORS"
;;
esac
if [[ $LINES_TO_EDIT == "ALL" ]]
then
TOTAL_ERRORS=$(cat "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|wc -l)
else
TOTAL_ERRORS=$(cat "$DIRECTORY""Sapo_""$NAME"/errors.tsv|wc -l)
fi
ERROR_LINE=1
while [ $ERROR_LINE -le $TOTAL_ERRORS ]
do
CURRENT_ERROR_LINE=$(cat "$DIRECTORY""Sapo_""$NAME"/errors.tsv|head -$ERROR_LINE|tail +$ERROR_LINE)
ERROR_TEXT_LINE=$(echo $CURRENT_ERROR_LINE|awk '{print $1}')
ERROR_WAV=$(echo $CURRENT_ERROR_LINE|awk '{print $2}')
if [[ $LINES_TO_EDIT == "ALL" ]]
then
CURRENT_ERROR_LINE=$ERROR_LINE
ERROR_TEXT_LINE=$ERROR_LINE
else
CURRENT_ERROR_LINE=$(cat "$DIRECTORY""Sapo_""$NAME"/errors.tsv|head -$ERROR_LINE|tail +$ERROR_LINE)
ERROR_TEXT_LINE=$(echo $CURRENT_ERROR_LINE|awk '{print $1}')
fi
ERROR_WAV="$(printf "%.6d" $ERROR_TEXT_LINE)".wav
TEXT_TO_CORRECT="$(cat "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|head -$ERROR_TEXT_LINE|tail +$ERROR_TEXT_LINE)"
GO=false
@ -44,8 +74,9 @@ do
--button='🗡 Split-Render':5 \
--button='🎵 Edit audio':7 \
--button='❌ Remove audio':6 \
--button='😃 Keep/Next':0 \
--text="Text of line $ERROR_TEXT_LINE :
--button='⬅️ Previous Line':8 \
--button='➡️ Next Line':0 \
--text="Text of line $ERROR_TEXT_LINE (of $TOTAL_ERRORS):
<span foreground='yellow'><b>$TEXT_TO_CORRECT</b></span>
@ -69,6 +100,7 @@ do
;;
7)audacity "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
;;
8) GO=true; ERROR_LINE=$(($ERROR_LINE - 2))
esac
done
((ERROR_LINE++))