diff --git a/sapo-fix-cli.png b/sapo-fix-cli.png new file mode 100644 index 0000000..7a75450 Binary files /dev/null and b/sapo-fix-cli.png differ diff --git a/sapo-fix-cli.sh b/sapo-fix-cli.sh index d289f18..62644e7 100755 --- a/sapo-fix-cli.sh +++ b/sapo-fix-cli.sh @@ -23,19 +23,25 @@ DIRECTORY=${FILE%/*}/ NAME=${FILE##*/};NAME=${NAME%.*} AUDIO_EDITOR="audacity" ####### 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 + +echo "╭────────────────────────────────────────────────────────────────╮ +│Select: │ +├─┬──────────────────────────────────────────────────────────────┤ +│1│ to edit ALL LINES │ +├─┼──────────────────────────────────────────────────────────────┤ +│2│ to edit only lines with detected errors │ +├─┼──────────────────────────────────────────────────────────────┤ +│3│ Exit │ +╰─┴──────────────────────────────────────────────────────────────╯" +read -p "Select: " C + case $C in + 3) exit ;; - 2) LINES_TO_EDIT="ALL" + 1) LINES_TO_EDIT="ALL" ;; - 3) LINES_TO_EDIT="ERRORS" + "") LINES_TO_EDIT="ALL" + ;; + 2) LINES_TO_EDIT="ERRORS" ;; esac @@ -63,6 +69,9 @@ do TEXT_TO_CORRECT="$(cat "$DIRECTORY""Sapo_""$NAME"/"$NAME"sentenced.txt|head -$ERROR_TEXT_LINE|tail +$ERROR_TEXT_LINE)" GO=false + Yellow="\033[1;33m" + bold=`tput bold` + normal=`tput sgr0` while [[ $GO == false ]] do @@ -70,24 +79,19 @@ do then killall mplayer > /dev/null 2>&1 ;mplayer -really-quiet "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV & fi - Yellow="\033[1;33m" - bold=`tput bold` - normal=`tput sgr0` BROWSE_NEXT=false DURATION=$(sox "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV -n stat 2>&1 |grep "Length"|sed 's/^.*\: *//;s/....$//') clear BOXTEXT=$(echo "$TEXT_TO_CORRECT"|fold -w 78 -s|sed 's/$/ /g'|sed 's/\(^.\{1,78\}\).*/\1/'|sed 's/^/│/g;s/$/│/g') - BOXDURATION=$(echo "Duration : $DURATION sec"|sed 's/$/ /g'|sed 's/\(^.\{1,78\}\).*/\1/'|sed 's/^/│/g;s/$/│/g') - BOXFIRSTLINE=$(echo "Text of line $ERROR_TEXT_LINE ( of $TOTAL_ERRORS ):"|sed 's/$/ /g'|sed 's/\(^.\{1,78\}\).*/\1/'|sed 's/^/│/g;s/$/│/g') - echo -e "╭──────────────────────────────────────────────────────────────────────────────╮ -$BOXFIRSTLINE -╰──────────────────────────────────────────────────────────────────────────────╯ + BOXDURATION=$(echo "Duration : $DURATION sec"|sed 's/$/ /g'|sed 's/\(^.\{1,38\}\).*/\1/') + BOXFIRSTLINE=$(echo "Text of line $ERROR_TEXT_LINE ( of $TOTAL_ERRORS ):"|sed 's/$/ /g'|sed 's/\(^.\{1,38\}\).*/\1/') + echo -e "╭──────────────────────────────────────┬───────────────────────────────────────╮ +│$BOXFIRSTLINE│ $BOXDURATION│ +╰──────────────────────────────────────┴───────────────────────────────────────╯ ${Yellow}╭──────────────────────────────────────────────────────────────────────────────╮ $BOXTEXT ╰──────────────────────────────────────────────────────────────────────────────╯${normal} -╭──────────────────────────────────────────────────────────────────────────────╮ -$BOXDURATION -├────────────────────────┬──────────────────────────┬──────────────────────────┤ +╭────────────────────────┬──────────────────────────┬──────────────────────────╮ │1. ⏩ Browse │ 5. ✂️ Trim │ 9. ⬅️ Previous │ ├────────────────────────┼──────────────────────────┼──────────────────────────┤ │2. ▶️ Play │ 6. 🪚 Split │ 10. ➡️ Next │ @@ -104,18 +108,18 @@ $BOXDURATION ;; 3) exit ;; - 2) if [[ -e "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV ]];then killall mplayer > /dev/null 2>&1 ;mplayer -really-quiet "$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 killall mplayer > /dev/null 2>&1 ;mplayer -really-quiet "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV & else echo "There is no file ""$DIRECTORY""Sapo_""$NAME"/"$ERROR_WAV"".";fi ;; - 4) killall mplayer > /dev/null 2>&1 ;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-fix.png --title="Line $ERROR_TEXT_LINE - $NAME")";if [ $? -eq 0 ];then tts --text "$s" --out_path "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV > /dev/null 2>&1 ;mplayer -really-quiet "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV&fi + 4) killall mplayer > /dev/null 2>&1 ;read -p "Enter the corrected line to render: " s; if [[ -n $s ]]; then echo "Please wait..."; tts --text "$s" --out_path "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV > /dev/null 2>&1 ;mplayer -really-quiet "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV&fi ;; 5)killall mplayer > /dev/null 2>&1 ;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 ;; - 6)killall mplayer > /dev/null 2>&1 ;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-fix.png --title="Line $ERROR_TEXT_LINE - $NAME")";if [ $? -eq 0 ];then s1="$(echo $s|sed 's/|.*$//')";s2="$(echo $s|sed 's/^.*|//')"; echo $s1;echo $s2 ; tts --text "$s1" --out_path "$DIRECTORY""Sapo_""$NAME"/1temp.wav > /dev/null 2>&1 ; tts --text "$s2" --out_path "$DIRECTORY""Sapo_""$NAME"/2temp.wav > /dev/null 2>&1 ;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;mplayer -really-quiet "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV &fi + 6)killall mplayer > /dev/null 2>&1 ;read -p "Enter the first half of line to render: " s1 ;read -p "Enter the second half of line to render: " s2 ;if [[ -n $s1 ]]&&[[ -n $s2 ]];then echo "Please wait..." ; tts --text "$s1" --out_path "$DIRECTORY""Sapo_""$NAME"/1temp.wav > /dev/null 2>&1 ; tts --text "$s2" --out_path "$DIRECTORY""Sapo_""$NAME"/2temp.wav > /dev/null 2>&1 ;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;mplayer -really-quiet "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV &fi ;; - 8)killall mplayer > /dev/null 2>&1 ; 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;GO=true + 8)killall mplayer > /dev/null 2>&1 ; if [[ -e "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV ]];then rm "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV;echo "* $DIRECTORY""Sapo_""$NAME"/"$ERROR_WAV"" has been deleted."; else echo "* There is no file ""$DIRECTORY""Sapo_""$NAME"/"$ERROR_WAV"". + Already deleted?";fi;GO=true ;; - 7)killall mplayer > /dev/null 2>&1 ;$AUDIO_EDITOR "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV > /dev/null 2>&1 + 7)killall mplayer > /dev/null 2>&1 ;echo "Opening audio editor...";$AUDIO_EDITOR "$DIRECTORY""Sapo_""$NAME"/$ERROR_WAV > /dev/null 2>&1 ;; 9)killall mplayer > /dev/null 2>&1 ; GO=true; ERROR_LINE=$(($ERROR_LINE - 2)) ;; @@ -123,11 +127,12 @@ $BOXDURATION ;; '') killall mplayer > /dev/null 2>&1 ;BROWSE_NEXT=true; GO=true ;; - 11)killall mplayer > /dev/null 2>&1 ;ERROR_LINE="$(yad --entry --height=40 --width=400 --text="Go To Line:" --entry-text="$ERROR_LINE" --window-icon=$HOME/git/sapo/sapo-fix.png --title="Go To Line ")";((ERROR_LINE--));GO=true + 11)killall mplayer > /dev/null 2>&1 ;read -p "Go To Line: " ERROR_LINE; if [[ -n $ERROR_LINE ]];then ((ERROR_LINE--));GO=true;fi esac done ((ERROR_LINE++)) done sox "$DIRECTORY""Sapo_""$NAME"/*.wav "$DIRECTORY""Sapo_""$NAME"/"$NAME".wav -yad --image "$HOME/git/sapo/sapo-fix.png" --height=40 --width=400 --title="${NAME} - Sapo" --text="Reading of ""$NAME"" is complete!" --window-icon=$HOME/git/sapo/sapo-fix.png +read -p "Reading of ""$NAME"" is complete! +Press Enter to exit: " db