mirror of https://gitlab.com/christosangel/sapo
update files
parent
d380638ac2
commit
7576fabf69
94
Sapo.sh
94
Sapo.sh
|
@ -22,6 +22,7 @@ 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
|
||||
sed -i 's/\.\.\./\.\n/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/\!/\!\n/g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # delimit to !
|
||||
sed -i 's/\?/\?\n/g' "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt # delimit to ?
|
||||
|
@ -94,9 +95,16 @@ while [ $LINE -le $TOTALLINES ]
|
|||
do
|
||||
CURRENTLINE=$(head -$LINE "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|tail +$LINE)
|
||||
FORMLINE="$(printf "%.6d" $LINE)"
|
||||
CURRENTLINEURI="$(echo "$CURRENTLINE" | jq -s -R -r @uri)"
|
||||
tts --text "$CURRENTLINE" --out_path "$DIRECTORY""Sapo_""$NAME"/$FORMLINE.wav
|
||||
|
||||
####error detection routine######
|
||||
CURRENTLINE_LENGTH=$(echo $CURRENTLINE|wc -m)
|
||||
WAV_LENGTH=$(jq -n $(sox "$DIRECTORY""Sapo_""$NAME"/$FORMLINE.wav -n stat 2>&1 |sed -n 's#^Length (seconds):[^0-9]*\([0-9.]*\)$#\1#p')-0.660)
|
||||
RATIO=$(jq -n $CURRENTLINE_LENGTH/$WAV_LENGTH|sed 's/\..*$//')
|
||||
if [ $RATIO -le 8 ]
|
||||
then
|
||||
echo $LINE $FORMLINE.wav $CURRENTLINE_LENGTH $WAV_LENGTH $RATIO>>"$DIRECTORY""Sapo_""$NAME"/errors.tsv
|
||||
fi
|
||||
###################################
|
||||
LINE100=$(( $LINE * 100 ))
|
||||
PERCENTAGE=$(( $LINE100 / $TOTALLINES))
|
||||
###Estimating Estimated time of arrival
|
||||
|
@ -138,6 +146,84 @@ done
|
|||
1) exit
|
||||
;;
|
||||
esac
|
||||
##### Error correction routine ######
|
||||
(
|
||||
TOTAL_ERRORS=$(cat "$DIRECTORY""Sapo_""$NAME"/errors.tsv|wc -l)
|
||||
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}')
|
||||
echo "#Attempting to fix error $ERROR_LINE of $TOTAL_ERRORS, line $ERROR_TEXT_LINE from $NAME.sentenced.txt"
|
||||
###################################
|
||||
ERROR_LINE100=$(( $ERROR_LINE * 100 ))
|
||||
ERROR_PERCENTAGE=$(( $ERROR_LINE100 / $TOTAL_ERRORS))
|
||||
echo "$ERROR_PERCENTAGE"
|
||||
tts --text "$(cat "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|head -$ERROR_TEXT_LINE|tail +$ERROR_TEXT_LINE)" --out_path "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
|
||||
|
||||
|
||||
((ERROR_LINE++))
|
||||
done
|
||||
)|
|
||||
yad --progress --height="40" --width="400" \
|
||||
--title="Sapo - Fixing Errors . . . ${NAME}" \
|
||||
--percentage=0 \
|
||||
--height=40 \
|
||||
--width=500 \
|
||||
--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)
|
||||
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}')
|
||||
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" \
|
||||
--height=40 --width=400 \
|
||||
--title="${NAME} - Sapo" \
|
||||
--button=gtk-cancel:1 \
|
||||
--button='▶️Play Audio':2 \
|
||||
--button='🔄Re-Render':3 \
|
||||
--button='✂️Trim Junk':4 \
|
||||
--button='🔪Split-Render':5 \
|
||||
--button='🎵Edit audio':7
|
||||
--button='❌Remove audio':6
|
||||
--button=gtk-ok:0 \
|
||||
--text="Text of line $ERROR_TEXT_LINE :
|
||||
|
||||
$TEXT_TO_CORRECT
|
||||
|
||||
What would you like to do?" \
|
||||
--window-icon=$HOME/git/sapo/sapo.png
|
||||
case $? in
|
||||
0) GO=true
|
||||
;;
|
||||
1) exit
|
||||
;;
|
||||
2) celluloid "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
|
||||
;;
|
||||
3) s="$(yad --entry --text="This is the original text of the line $ERROR_TEXT_LINE.
|
||||
Edit as you wish, then hit OK to render." --entry-text="$TEXT_TO_CORRECT" --entry-label="Line:" --window-icon=$HOME/git/sapo/sapo.png)";tts --text "$s" --out_path "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
|
||||
;;
|
||||
4)sox -V3 "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV "$DIRECTORY""Sapo_""$NAME"/temp.wav silence 1 0.50 0.1% 1 0.5 0.1%;sox "$DIRECTORY""Sapo_""$NAME"/temp.wav "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV pad 0 0.5;rm "$DIRECTORY""Sapo_""$NAME"/temp.wav
|
||||
;;
|
||||
5)s="$(yad --entry --text="Split the printed text roughly in half with the pipe symbol (|), so that it can be rendered in two batches: " --entry-text="$TEXT_TO_CORRECT" --entry-label="Line:" --window-icon=$HOME/git/sapo/sapo.png)";s1="$(echo $s|sed 's/|.*$//')";s2="$(echo $s|sed 's/^.*|//')"; echo $s1;echo $s2 ; tts --text "$s1" --out_path "$DIRECTORY""Sapo_""$NAME"/1temp.wav; tts --text "$s2" --out_path "$DIRECTORY""Sapo_""$NAME"/2temp.wav;sox "$DIRECTORY""Sapo_""$NAME"/1temp.wav "$DIRECTORY""Sapo_""$NAME"/2temp.wav "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV ; rm "$DIRECTORY""Sapo_""$NAME"/1temp.wav "$DIRECTORY""Sapo_""$NAME"/2temp.wav
|
||||
;;
|
||||
6) rm "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
|
||||
;;
|
||||
7)audacity "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
|
||||
;;
|
||||
esac
|
||||
done
|
||||
((ERROR_LINE++))
|
||||
done
|
||||
sox "$DIRECTORY""Sapo_""$NAME"/*.wav "$DIRECTORY""Sapo_""$NAME"/"$NAME".wav
|
||||
|
||||
yad --image "$HOME/git/sapo/sapo.png" --height=40 --width=400 --title="${NAME} - Sapo" --text="Reading of ""$NAME"" is complete!" --window-icon=$HOME/git/sapo/sapo.png
|
||||
yad --image "$HOME/git/sapo/sapo.png" --height=40 --width=400 --title="${NAME} - Sapo" --text="Reading of ""$NAME"" is complete! Check detected errors to be sure!" --window-icon=$HOME/git/sapo/sapo.png
|
||||
|
|
|
@ -30,7 +30,7 @@ s/Jesus/JeeZuss/g
|
|||
s/Christ/Craist/g
|
||||
s/island/eyeland/g;s/Island/eyeland/g
|
||||
s/ocean/ohshun/g;s/Ocean/ohshun/g
|
||||
s/listen/lee\ sin/g;s/Listen/lee\ sin/g
|
||||
s/listen/lyssen/g;s/Listen/lyssen/g
|
||||
s/colour/color/g;s/Colour/color/g
|
||||
s/gear/ghear/g
|
||||
s/Mrs/missuz/g
|
||||
|
@ -62,4 +62,8 @@ s/biscuit/biskit/g;s/Biscuit/biskit/g
|
|||
s/alas/alass/g;s/Alas/alass/g
|
||||
s/anger/angher/g;s/Anger/angher/g
|
||||
s/breath /breth /g;s/Breath /breth /g
|
||||
s/tongue/tung/g
|
||||
s/loophole/loop\ hole/g;s/Loophole/loop\ hole/g
|
||||
s/Shiva/sheeva/g
|
||||
s/\ mme/madame/g;s/Mme/madame/g
|
||||
|
||||
|
|
Loading…
Reference in New Issue