update files

main
Christos Angelopoulos 2022-03-22 03:37:47 +02:00
parent 0ecb7dd084
commit 06d6812bff
2 changed files with 74 additions and 73 deletions

92
Sapo.sh
View File

@ -1,22 +1,22 @@
#! /bin/bash
# ▗▄▖
#▗▛▀▜
#▐▙ ▟██▖▐▙█▙ ▟█▙
# ▗▄▖
#▗▛▀▜
#▐▙ ▟██▖▐▙█▙ ▟█▙
# ▜█▙ ▘▄▟▌▐▛ ▜▌▐▛ ▜▌
# ▜▌▗█▀▜▌▐▌ ▐▌▐▌ ▐▌
#▐▄▄▟▘▐▙▄█▌▐█▄█▘▝█▄█▘
# ▀▀▘ ▀▀▝▘▐▌▀▘ ▝▀▘
# ▐▌
# ▀▀▘ ▀▀▝▘▐▌▀▘ ▝▀▘
# ▐▌
# a tts bash script by Christos Angelopoulos, February 2022
#converts txt to wav
#using the all powerful https://github.com/coqui-ai/TTS
FILE="$(yad --file-selection --filename=Desktop --height='400' --width='800' --title='Sapo - Select File to Read' --window-icon=$HOME/git/sapo/sapo.png --hscroll-policy=never --vscroll-policy=never)"
case $? in
0)
;;
case $? in
0)
;;
1) exit
;;
;;
esac
DIRECTORY=${FILE%/*}/
NAME=${FILE##*/}
@ -62,22 +62,22 @@ do
echo "comma count : "$COMMA_COUNT
if [ $COMMA_COUNT -gt 2 ]
then
echo "commas > 2"
echo "commas > 2"
echo $DELIM"s/\,/\n/"$(($COMMA_COUNT - 2))>"$DIRECTORY""Sapo_""$NAME"/script.sed
sed -i -f "$DIRECTORY""Sapo_""$NAME"/script.sed "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt
fi
if [ $COMMA_COUNT -le 2 ]
then
if [ $COMMA_COUNT -le 2 ]
then
echo "No commas to delimit to, proceed delimiting with spaces(limit 30)"
SPACE_COUNT=$(echo "$CUR_DELIM_LINE"| sed -e 's/\(.\)/\1\n/g' | grep " " | wc -l)
echo "Space count : "$SPACE_COUNT
echo $DELIM"s/\ /\n/"$(($SPACE_COUNT - 30))>"$DIRECTORY""Sapo_""$NAME"/script.sed
sed -i -f "$DIRECTORY""Sapo_""$NAME"/script.sed "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt
sed -i -f "$DIRECTORY""Sapo_""$NAME"/script.sed "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt
fi
CUR_DELIM_LINE=$(cat "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|head -$DELIM|tail +$DELIM)
CHAR_COUNT=$(echo "$CUR_DELIM_LINE"|wc -m)
done
echo "Task completed for line "$DELIM
((DELIM--))
@ -86,18 +86,18 @@ done
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
case $? in
0)
;;
1) exit
;;
2) xed "$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-ok:0 --text="If you are done editing $NAME\sentenced.txt, <span foreground='yellow'><b>press OK</b></span> to continue!" --window-icon=$HOME/git/sapo/sapo.png
case $? in
0)
;;
case $? in
0)
;;
1) exit
;;
esac
2) xed "$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-ok:0 --text="If you are done editing $NAME\sentenced.txt, <span foreground='yellow'><b>press OK</b></span> to continue!" --window-icon=$HOME/git/sapo/sapo.png
case $? in
0)
;;
1) exit
;;
esac
esac
TOTALLINES=$(cat "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|wc -l)
LINE=1
@ -105,7 +105,7 @@ LINE=1
while [ $LINE -le $TOTALLINES ]
do
CURRENTLINE=$(head -$LINE "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|tail +$LINE)
FORMLINE="$(printf "%.6d" $LINE)"
FORMLINE="$(printf "%.6d" $LINE)"
tts --text "$CURRENTLINE" --out_path "$DIRECTORY""Sapo_""$NAME"/$FORMLINE.wav
####error detection routine######
CURRENTLINE_LENGTH=$(echo $CURRENTLINE|wc -m)
@ -136,7 +136,7 @@ do
then
MINUTESTRING=""
fi
#echo line starting with #, updated in the yad progress bar window
#echo line starting with #, updated in the yad progress bar window
echo "# Reading line $(( $LINE + 1)) of $TOTALLINES from "$NAME" ($PERCENTAGE%). Roughly remaining : "$HOURSTRING" "$MINUTESTRING" " $SECMLEFT" secs"
echo "$PERCENTAGE"
((LINE++))
@ -150,12 +150,12 @@ done
--window-icon=$HOME/git/sapo/sapo.png \
--image "$HOME/git/sapo/sapo_progress.png" \
--auto-close
#--text="Preparing to read..." \
case $? in
0)
;;
#--text="Preparing to read..." \
case $? in
0)
;;
1) exit
;;
;;
esac
##### Error correction routine ######
(
@ -172,8 +172,8 @@ do
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
)|
@ -184,7 +184,7 @@ done
--width="500" \
--window-icon=$HOME/git/sapo/sapo.png \
--image "$HOME/git/sapo/sapo_progress.png" \
--auto-close
--auto-close
####### FIXING ERRORS ONE BY ONE ############
TOTAL_ERRORS=$(cat "$DIRECTORY""Sapo_""$NAME"/errors.tsv|wc -l)
ERROR_LINE=1
@ -210,29 +210,29 @@ do
--button='😃 Keep/Next':0 \
--text="Text of line $ERROR_TEXT_LINE :
<span foreground='yellow'><b>$TEXT_TO_CORRECT</b></span>
<span foreground='yellow'><b>$TEXT_TO_CORRECT</b></span>
<i>What would you like to do?</i>" \
--window-icon=$HOME/git/sapo/sapo.png
case $? in
0) GO=true
;;
case $? in
0) GO=true
;;
1) GO=true;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
;;
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
;;
3) s="$(yad --entry --width="600" --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" --window-icon=$HOME/git/sapo/sapo.png --title="Line $ERROR_TEXT_LINE - $NAME")";tts --text "$s" --out_path "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
Edit as you wish, then hit OK to render." --entry-text="$TEXT_TO_CORRECT" --window-icon=$HOME/git/sapo/sapo.png --title="Line $ERROR_TEXT_LINE - $NAME")";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 --width="600" --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" --window-icon=$HOME/git/sapo/sapo.png --title="Line $ERROR_TEXT_LINE - $NAME")";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) if [[ -e "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV ]];then rm "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV;notify-send "$DIRECTORY""Sapo_""$NAME"/"$ERROR_WAV"" has been deleted."; else notify-send "There is no file ""$DIRECTORY""Sapo_""$NAME"/"$ERROR_WAV"". Already deleted?";fi
;;
7)audacity "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
7)audacity "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
;;
esac
done

View File

@ -1,23 +1,23 @@
#!/bin/bash
#
# ▗▄▖ ▄▄ █
#▗▛▀▜ ▐▛▀ ▀
#
# ▗▄▖ ▄▄ █
#▗▛▀▜ ▐▛▀ ▀
#▐▙ ▟██▖▐▙█▙ ▟█▙ ▐███ ██ ▝█ █▘
# ▜█▙ ▘▄▟▌▐▛ ▜▌▐▛ ▜▌ ▐▌ █ ▐█▌
# ▜▌▗█▀▜▌▐▌ ▐▌▐▌ ▐▌ ██▌ ▐▌ █ ▗█▖
#▐▄▄▟▘▐▙▄█▌▐█▄█▘▝█▄█▘ ▐▌ ▗▄█▄▖ ▟▀▙
# ▜█▙ ▘▄▟▌▐▛ ▜▌▐▛ ▜▌ ▐▌ █ ▐█▌
# ▜▌▗█▀▜▌▐▌ ▐▌▐▌ ▐▌ ██▌ ▐▌ █ ▗█▖
#▐▄▄▟▘▐▙▄█▌▐█▄█▘▝█▄█▘ ▐▌ ▗▄█▄▖ ▟▀▙
# ▀▀▘ ▀▀▝▘▐▌▀▘ ▝▀▘ ▝▘ ▝▀▀▀▘▝▀ ▀▘
# ▐▌
#
# ▐▌
#
# a tts bash script by Christos Angelopoulos, February 2022
#Attempts to fix errors in wav files generated by sapo.sh (txt to wav)
#using the all powerful https://github.com/coqui-ai/TTS
FILE="$(yad --file-selection --filename=Desktop --height='400' --width='800' --title='Sapo-fix' --window-icon=$HOME/git/sapo/sapo-fix.png --hscroll-policy=never --vscroll-policy=never)"
case $? in
0)
;;
case $? in
0)
;;
1) exit
;;
;;
esac
DIRECTORY=${FILE%/*}/
NAME=${FILE##*/}
@ -31,6 +31,7 @@ do
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" \
@ -45,28 +46,28 @@ do
--button='❌ Remove audio':6 \
--button='😃 Keep/Next':0 \
--text="Text of line $ERROR_TEXT_LINE :
<span foreground='yellow'><b>$TEXT_TO_CORRECT</b></span>
<span foreground='yellow'><b>$TEXT_TO_CORRECT</b></span>
-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
case $? in
0) GO=true
;;
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-fix.png --title="${NAME} - Sapo")";tts --text "$s" --out_path "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
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
;;
3) s="$(yad --entry --width="600" --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" --window-icon=$HOME/git/sapo/sapo.png --title="Line $ERROR_TEXT_LINE - $NAME")";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-fix.png --title="${NAME} - Sapo")";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
5)s="$(yad --entry --width="600" --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" --window-icon=$HOME/git/sapo/sapo.png --title="Line $ERROR_TEXT_LINE - $NAME")";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
;;
7)audacity "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
6) if [[ -e "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV ]];then rm "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV;notify-send "$DIRECTORY""Sapo_""$NAME"/"$ERROR_WAV"" has been deleted."; else notify-send "There is no file ""$DIRECTORY""Sapo_""$NAME"/"$ERROR_WAV"". Already deleted?";fi
;;
7)audacity "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV
;;
esac
done