├── t2a.jpg
├── wiki.md
├── env.list
├── m2a
├── a2sk
├── c2c
├── t2i
├── t2c
├── i2i
├── q2t
├── s2s
├── p2t
├── a2s
├── a2t
├── README.md
├── p2c
├── m2t
├── t2t
├── t2tr
├── t2a
├── p2a
└── a2a
/t2a.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GabrieleRisso/aiyu/HEAD/t2a.jpg
--------------------------------------------------------------------------------
/wiki.md:
--------------------------------------------------------------------------------
1 | WIP
2 |
3 | ### t2a: text to audio
4 |
5 | asks gpt3.5turbo and produce an audio response.
6 |
7 | 4 ways of using it:
8 |
9 | * **t2a** file.txt
10 | * **t2a** "your text here"
11 | * **t2a** and a prompt will appear asking you to input text
12 | * create a .txt file at /dev/shm/file.txt and then run **t2a**
13 |
14 |
15 |
--------------------------------------------------------------------------------
/env.list:
--------------------------------------------------------------------------------
1 | #your OPENAI key
2 | OPENAI_API_KEY=""
3 |
4 | #your editor of choice
5 | EDITOR="nano"
6 |
7 | #your preferred language
8 | #lang=${lang:-$(echo ${LANG:0:2})};
9 |
10 | #the name of the session used to name generated files
11 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
12 |
13 | #with of your terminal
14 | #COLUMNS="150"
15 |
16 |
17 | #files Generated by Whisper
18 | audiow="/dev/shm/audiow_$session.mp3"
19 | voicew="/dev/shm/voicew_$session.mp3"
20 | textw="/dev/shm/textw_$session.txt"
21 | tradw="/dev/shm/tradw_$session.txt"
22 | subw="/dev/shm/subw_$session.srt"
23 | promptw="/dev/shm/promptw_$session.txt"
24 |
25 | #ai Generated files
26 | promptg="/dev/shm/promptg_$session.txt"
27 | voiceg="/dev/shm/vocieg_$session.mp3"
28 | audiog="/dev/shm/audiog_$session.mp3"
29 | textg="/dev/shm/textg_$session.txt"
30 | subg="/dev/shm/subg_$session.srt"
31 | tradg="/dev/shm/tradg_$session.txt"
32 |
33 | # _MODELS = {
34 | # "tiny": "https://huggingface.co/datasets/jordimas/whisper-ct2-v2/resolve/main/dc6a7765cdc8ae7822b1c3068a2f966eddc2549eda7e67406cae915a8c19430c.tiny/",
35 | # "tiny.en": "https://huggingface.co/datasets/jordimas/whisper-ct2-v2/resolve/main/c4d1be0a2003ce00bb721abd23e7a34925a6f0c0d21d5c416f11c763ee7f7b15.tiny-en/",
36 | # "base": "https://huggingface.co/datasets/jordimas/whisper-ct2-v2/resolve/main/d7c4df31737340263ce37933bda1e77a38367dbb09cda7433ce1ee0c58ce1a60.base/",
37 | # "base.en": "https://huggingface.co/datasets/jordimas/whisper-ct2-v2/resolve/main/2ca96777261aeadd48e30bc5f26fd3ee462f4921dbc1f38dfd826a67c761c9b2.base-en/",
38 | # "small": "https://huggingface.co/datasets/jordimas/whisper-ct2-v2/resolve/main/936cd99363be80fa388c0c5006e846d8cd42834c6cf8156a7c300723a3bf929f.small/",
39 | # "small.en": "https://huggingface.co/datasets/jordimas/whisper-ct2-v2/resolve/main/e2c14bb0f6a8a69afe12fbe1d82fa0c41494d4bde9615bdf399da5665f43cbc4.small-en/",
40 | # "medium": "https://huggingface.co/datasets/jordimas/whisper-ct2-v2/resolve/main/d8b91e278db3041c3b41bf879716281edf5cfa7b0025823cc174b5429877d2bc.medium/",
41 | # "medium.en": "https://huggingface.co/datasets/jordimas/whisper-ct2-v2/resolve/main/22d42d3e69ce9149bfd52c07d357e4cb72b992fb602805d6bb39f331400d6742.mediu-en/",
42 | # "large-v1": "https://huggingface.co/datasets/jordimas/whisper-ct2-v2/resolve/main/ea44e7a9609bd21a604b28880b85fc7dc2c373876c627a7553ce5440a8c406c1.large/",
43 | # "large-v2": "https://huggingface.co/datasets/jordimas/whisper-ct2-v2/resolve/main/ff9f410b63b3d996274c895f6209e9b9ab01d497815b21c2d35ae336ab7d7f20.large-v2/",
44 | # }
45 |
46 |
47 |
--------------------------------------------------------------------------------
/m2a:
--------------------------------------------------------------------------------
1 | # Small but handy functions. For Personal use only.
2 | # Use it at your own risk!
3 | # Author: Gabriele Risso License: Apache 2.0
4 |
5 | lang=${lang:-$(echo ${LANG:0:2})};
6 |
7 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
8 |
9 | audiow="/dev/shm/audiow_$session.mp3"
10 | voicew="/dev/shm/voicew_$session.mp3"
11 |
12 | voiceg="/dev/shm/vocieg_$session.mp3"
13 | audiog="/dev/shm/audiog_$session.mp3"
14 | textg="/dev/shm/textg_$session.txt"
15 |
16 | input=""
17 | output=""
18 |
19 | if ! type m2a 2>/dev/null 1>&2;
20 | then
21 | m2a ()
22 | {
23 | if ! python3 -c "import pvrecorder" 2>/dev/null 1>&2;
24 | then
25 | echo "PV_Recorder is not installed on your system. Install it: pip3 install pvrecorder and re-try" >&2;
26 | echo "m2a-pvrecorder is disabled" >&2;
27 | elif ! command -v gum --version 2>/dev/null 1>&2;
28 | then
29 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
30 | else
31 | if ! type m2a-pvrecorder 2>/dev/null 1>&2;
32 | then
33 | m2a-pvrecorder ()
34 | {
35 |
36 | set -uo pipefail;
37 |
38 | echo '{{ Bold "[!] record started" }}' | gum format -t template >&2;
39 |
40 | local start=$SECONDS;
41 |
42 | local output="$1";
43 | local output=${output:-$(echo $audiow)};
44 |
45 | gum style "using microphone for audio recording." "INPUT: microphone" "OUTPUT: audio saved at $output" "DEVICE: default mic" "SESSION: $session" --foreground 15 --border-foreground 50 --border rounded --width="$(($COLUMNS -4))" --italic --margin "1 1" --padding "0 1";
46 |
47 | # subtitle to text: https://github.com/Picovoice/pvrecorder/tree/main/sdk/python
48 |
49 | wget -qO - https://raw.githubusercontent.com/Picovoice/pvrecorder/main/sdk/python/demo.py > /dev/shm/recorder.py
50 | echo '{{ Bold "[+] Recording has started! stop it with CTRL+C" }}' | gum format -t template >&2;
51 | python3 /dev/shm/recorder.py --output_path $output;
52 |
53 | echo '{{ Bold "[t] completed in '$((SECONDS-start))' seconds" }}' | gum format -t template >&2;
54 | echo '{{ Bold "[+] recorder OK" }}' | gum format -t template >&2;
55 |
56 | echo '{{ Bold "[?] What now? press ESC to exit." }}' | gum format -t template >&2;
57 | echo ' ' >&2;
58 |
59 | CHOICE=$(gum choose --item.foreground 250 "edit function sourcecode" "play recorded audio" "help" "contribute to aiyu");
60 | [[ "$CHOICE" == "edit function sourcecode" ]] && $EDITOR $(gum filter --value="a2t" --height=9);
61 | [[ "$CHOICE" == "play recorded audio" ]] && ffplay -nodisp -autoexit -loglevel fatal $output;
62 | [[ "$CHOICE" == "help" ]] && glow -p README.md;
63 | [[ "$CHOICE" == "contribute to aiyu" ]] && echo "Great! I thought so, thank you for making $(gum style --bold "aiyu") the best! leave a $(gum style --bold "star") if you like this. Go to: https://github.com/GabrieleRisso/aiyu";
64 |
65 | }
66 | else
67 | echo '{{ Bold "m2a-pvrecorder is set on the system" }}' | gum format -t template >&2;
68 | fi
69 | fi
70 |
71 | m2a-pvrecorder "$1";
72 | }
73 | else
74 | echo '{{ Bold "m2a is set on the system" }}' | gum format -t template >&2;
75 | fi
76 |
--------------------------------------------------------------------------------
/a2sk:
--------------------------------------------------------------------------------
1 | # Small but handy functions. For Personal use only.
2 | # Use it at your own risk!
3 | # Author: Gabriele Risso License: Apache 2.0
4 |
5 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
6 |
7 | voiceg="/dev/shm/voiceg_$session.mp3"
8 | voicew="/dev/shm/voicew_$session.mp3"
9 |
10 | audiog="/dev/shm/audiog_$session.mp3"
11 |
12 | input=""
13 | output=""
14 |
15 | if ! type a2sk 2>/dev/null 1>&2;
16 | then
17 | a2sk ()
18 | {
19 | if ! command -v ffplay --version 2>/dev/null 1>&2;
20 | then
21 | echo "ffplay is not installed on your system. Install it and re-try" >&2;
22 | echo "a2sk-ffplay is disabled" >&2;
23 | elif ! command -v gum --version 2>/dev/null 1>&2;
24 | then
25 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
26 | else
27 | if ! type a2sk-ffplay 2>/dev/null 1>&2;
28 | then
29 | a2sk-ffplay ()
30 | {
31 |
32 | set -euo pipefail;
33 |
34 | echo '{{ Bold "[!] ffplay started" }}' | gum format -t template >&2;
35 |
36 | local start=$SECONDS;
37 |
38 | local input="$1";
39 |
40 | #select the lastly created file.mp3 (1 minute old) located in /dev/shm/ OR select a local .mp3 file
41 | local newest_file="";
42 | local newest_file=$(find /dev/shm/ -cmin -1 -type f -name "*.mp3" -printf "%T@ %p\n" 2>/dev/null | sort -n | tail -1 | awk '{print $2}');
43 | if [ -n "$newest_file" ]; then
44 | echo '{{ Bold "[>] Selecting most recent audio file --> '$newest_file'" }}' | gum format -t template >&2;
45 | local input=${input:-$(echo $newest_file)};
46 | else
47 | echo '{{ Bold "[+] Select a mp3 file. Use keyboard arrows < > to traverse directories, up or down arrows to move in the directory." }}' | gum format -t template >&2;
48 | local input=$(gum file $PWD);
49 | fi
50 |
51 | gum style "using ffplay to reproduce audio with speaker." "INPUT: audio saved at $input" "OUTPUT: default audio speaker" "SESSION: $session" --foreground 15 --border-foreground 50 --border rounded --width="$(($COLUMNS -4))" --italic --margin "1 1" --padding "0 1";
52 |
53 | ffplay -nodisp -autoexit -loglevel fatal $input;
54 |
55 | echo '{{ Bold "[t] completed in '$((SECONDS-start))' seconds" }}' | gum format -t template >&2;
56 | echo '{{ Bold "[+] ffplay OK" }}' | gum format -t template >&2;
57 |
58 | echo '{{ Bold "[?] What now? press ESC to exit." }}' | gum format -t template >&2;
59 | echo ' ' >&2;
60 | CHOICE=$(gum choose --item.foreground 250 "edit function sourcecode" "play input audio" "help" "contribute to aiyu");
61 | [[ "$CHOICE" == "edit function sourcecode" ]] && $EDITOR $(gum filter --value="a2t" --height=9);
62 | [[ "$CHOICE" == "play input audio" ]] && ffplay -nodisp -autoexit -loglevel fatal $input;
63 | [[ "$CHOICE" == "help" ]] && glow -p README.md;
64 | [[ "$CHOICE" == "contribute to aiyu" ]] && echo "Great! I thought so, thank you for making $(gum style --bold "aiyu") the best! leave a $(gum style --bold "star") if you like this. Go to: https://github.com/GabrieleRisso/aiyu";
65 |
66 | return 1;
67 | }
68 | else
69 | echo '{{ Bold "a2sk-ffplay is set on the system" }}' | gum format -t template >&2;
70 | fi
71 | fi
72 |
73 | a2sk-ffplay "$1";
74 | }
75 | else
76 | echo '{{ Bold "a2sk is set on the system" }}' | gum format -t template >&2;
77 | fi
78 |
--------------------------------------------------------------------------------
/c2c:
--------------------------------------------------------------------------------
1 | # Small but handy functions. For Personal use only.
2 | # Use it at your own risk!
3 | # Author: Gabriele Risso License: Apache 2.0
4 |
5 | lang=${lang:-$(echo ${LANG:0:2})};
6 |
7 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
8 |
9 |
10 |
11 |
12 |
13 | #promptw="/dev/shm/promptw_$session.txt"
14 | #promptg="/dev/shm/promptg_$session.txt"
15 |
16 |
17 | #textg="/dev/shm/textg_$session.txt"
18 | codeg="/dev/shm/codeg_$session"
19 |
20 | input=""
21 | output=""
22 | tmp=""
23 |
24 | if ! type c2c 2>/dev/null 1>&2;
25 | then
26 | c2c ()
27 | {
28 | if ! command -v npm --version 2>/dev/null 1>&2;
29 | then
30 | echo " npm is not installed on your system. Install it: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#using-a-node-version-manager-to-install-nodejs-and-npm and re-try" >&2;
31 | echo " c2c is disabled" >&2;
32 | elif ! command -v gum --version 2>/dev/null 1>&2;
33 | then
34 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
35 | else
36 | if ! type c2c-codetrans 2>/dev/null 1>&2;
37 | then
38 |
39 | #echo '{{ Bold "[*] language: '$lang' " }}' | gum format -t template >&2;
40 | echo '{{ Bold "[*] session: '$session' " }}' | gum format -t template >&2;
41 |
42 | c2c-codetrans ()
43 | {
44 |
45 | echo '{{ Bold "[!] c2c-codetrans started" }}' | gum format -t template >&2;
46 |
47 | if [ -z ${OPENAI_API_KEY+x} ]; then echo '{{ Bold "[!] OPENAI_API_KEY not set! type: export OPENAI_API_KEY=\"your-key-here\" " }}' | gum format -t template >&2; return 1; fi
48 |
49 | local start=$SECONDS;
50 |
51 | echo '{{ Bold "[+] copy-paste your openai api key:'$OPENAI_API_KEY' " }}' | gum format -t template >&2;
52 |
53 |
54 | #-------------------------------------x
55 | gum spin -s points --show-output --spinner.foreground="50" --title.bold --spinner.margin="0 1" --title "using Git to install code translator web interface..." --\
56 | git clone https://github.com/mckaywrigley/ai-code-translator.git; cd ai-code-translator/ && npm i;
57 |
58 | echo '{{ Bold "[t] open your browser at the below address: startup done in '$((SECONDS-start))' seconds" }}' | gum format -t template >&2;
59 |
60 | #run web interface
61 | echo '{{ Bold "[+] copy-paste your traduction to : '$codeg' " }}' | gum format -t template >&2;
62 |
63 | echo '{{ Bold "[?] press CTRL-C to exit." }}' | gum format -t template >&2;
64 | echo ' ' >&2;
65 |
66 | npm run dev &
67 |
68 | open http://localhost:3000;
69 |
70 | #porobably we can inject code and parameters can be auto detected like t2tr --> c2tr. only needed params is c2tr $langto, like in t2tr fr ( translate text in french)
71 | #-------------------------------------x
72 |
73 | while read -r -n1 key
74 | do
75 | # if input == ESC key
76 | if [[ $key == $'\e' ]];
77 | then
78 | break;
79 | fi
80 |
81 | CHOICE=$(gum choose --item.foreground 250 "edit function sourcecode" "edit output text in glow" "edit input text in glow" "help" "contribute to aiyu");
82 | [[ "$CHOICE" == "edit function sourcecode" ]] && $EDITOR $(gum filter --value="c2c"code-to-codeeight=9);
83 | [[ "$CHOICE" == "help" ]] && glow -p README.md;
84 | [[ "$CHOICE" == "contribute to aiyu" ]] && echo "Great! I thought so, thank you for making $(gum style --bold "aiyu") is the best! leave a $(gum style --bold "star") if you like this. Go to: https://github.com/GabrieleRisso/aiyu";
85 |
86 | done;
87 |
88 | }
89 | else
90 | echo '{{ Bold " c2c-codetrans is set on the system." }}' | gum format -t template >&2;
91 | fi
92 | fi
93 |
94 | c2c-codetrans;
95 | }
96 | else
97 | echo '{{ Bold "c2c installed on the system" }}' | gum format -t template >&2;
98 | fi
99 |
100 |
--------------------------------------------------------------------------------
/t2i:
--------------------------------------------------------------------------------
1 | # Small but handy functions. For Personal use only.
2 | # Use it at your own risk!
3 | # Author: Gabriele Risso License: Apache 2.0
4 |
5 | #fboulnois_stable-diffusion-docker_ Run the official Stable Diffusion releases in a Docker container with txt2img, img2img, depth2img, pix2pix, upscale4x, and inpaint.
6 |
7 | filter=filter.rnn && wget -qO $filter https://raw.githubusercontent.com/GregorR/rnnoise-models/master/somnolent-hogwash-2018-09-01/sh.rnnn
8 |
9 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
10 |
11 |
12 |
13 |
14 | audiow="/dev/shm/audiow_$session.mp3"
15 | voicew="/dev/shm/voicew_$session.mp3"
16 | textw="/dev/shm/textw_$session.txt"
17 | tradw="/dev/shm/tradw_$session.txt"
18 | subw="/dev/shm/subw_$session.srt"
19 | imgw="/dev/shm/imgw_$session.png"
20 |
21 |
22 | voiceg="/dev/shm/vocieg_$session.mp3"
23 | audiog="/dev/shm/audiog_$session.mp3"
24 | textg="/dev/shm/textg_$session.txt"
25 | askg="/dev/shm/askg_$session.txt"
26 | subg="/dev/shm/subg_$session.srt"
27 | imgg="/dev/shm/imgg_$session.png"
28 |
29 |
30 | input=""
31 | output=""
32 | tmp=""
33 |
34 | #not tested
35 |
36 | if ! type t2i 2>/dev/null 1>&2;
37 | then
38 | t2i ()
39 | {
40 |
41 | if ! command -v docker --version 2>/dev/null 1>&2;
42 | then
43 | echo " docker is not installed on your system. Install it: https://docs.docker.com/engine/install and re-try" >&2;
44 | echo "sdimg is disabled" >&2;
45 | elif ! command -v gum --version 2>/dev/null 1>&2;
46 | then
47 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
48 | echo "sdimg is disabled" >&2;
49 | else
50 | if ! type sdimg 2>/dev/null 1>&2;
51 | then
52 |
53 | echo '{{ Bold "[*] session: '$session' " }}' | gum format -t template >&2;
54 |
55 | sdimg ()
56 | {
57 |
58 |
59 | echo '{{ Bold "[!] sgpt started" }}' | gum format -t template >&2;
60 |
61 |
62 | input="$1";
63 | local newest_file=$(stat -c '%Y %n' /dev/shm/*.png | sort -nr | head -n1 | cut -d' ' -f2);
64 |
65 |
66 | echo '{{ Bold "[!] most recent file --> '$newest_file'" }}' | gum format -t template >&2;
67 |
68 | [ -f $newest_file ] && local input=${input:-$(echo $newest_file)} || local input=${input:-$(echo $(gum input --char-limit=4000 --placeholder="Type something here, just ask me!" --width="$(($COLUMNS-5))" --header="I'm an AI use me wisely!" --header.italic --header.border="rounded" --header.foreground="50" ))};
69 |
70 | #takes function input or if empty asks for inputs
71 |
72 | if [ -z "$input" ];
73 | then
74 | echo "No input" >&2;
75 | return 1;
76 | fi
77 |
78 | echo $input > $askg >&2;
79 |
80 | gum spin -s points --show-output --spinner.foreground="50" --title.bold --spinner.margin="0 1" --title "using Docker to interact with sgpt..." --\
81 | ./build.sh run "$input"; #https://github.com/fboulnois/stable-diffusion-docker#huggingface-token
82 |
83 | local output=$(stat -c '%Y %n' $PWD/output/*.png | sort -nr | head -n1 | cut -d' ' -f2);
84 |
85 |
86 | if [ -z "$output" ];
87 | then
88 | echo '{{ Bold "someting went wrong, check https://github.com/fboulnois/stable-diffusion-docker and try again...' | gum format -t template >&2;
89 | return 1;
90 | fi
91 |
92 | gum style "INPUT: saved $askg" "$input" "OUTPUT: image saved at "$output" "SESSION: $session" --foreground 15 --border-foreground 50 --border rounded --width="$(($COLUMNS -4))" --italic --margin "1 1" --padding "0 1";
93 |
94 |
95 | echo '{{ Bold "[+] sdimg started" }}' | gum format -t template >&2;
96 | }
97 | else
98 | echo '{{ Color "50" "0" " t2i-sdimg is set on the system." }}' | gum format -t template >&2;
99 | fi
100 | fi
101 |
102 |
103 | t2i-sdimg "$1";
104 | }
105 | else
106 | echo '{{ Bold "t2i is set on the system" }}' | gum format -t template >&2;
107 | fi
108 |
--------------------------------------------------------------------------------
/t2c:
--------------------------------------------------------------------------------
1 | # Small but handy functions. For Personal use only.
2 | # Use it at your own risk!
3 | # Author: Gabriele Risso License: Apache 2.0
4 |
5 |
6 | lang=${lang:-$(echo ${LANG:0:2})};
7 |
8 | filter=filter.rnn && wget -qO $filter https://raw.githubusercontent.com/GregorR/rnnoise-models/master/somnolent-hogwash-2018-09-01/sh.rnnn
9 |
10 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
11 |
12 | audiow="/dev/shm/audiow_$session.mp3"
13 | voicew="/dev/shm/voicew_$session.mp3"
14 | textw="/dev/shm/textw_$session.txt"
15 | tradw="/dev/shm/tradw_$session.txt"
16 | subw="/dev/shm/subw_$session.srt"
17 | codew="/dev/shm/codew_$session.txt"
18 |
19 |
20 | voiceg="/dev/shm/vocieg_$session.mp3"
21 | audiog="/dev/shm/audiog_$session.mp3"
22 | textg="/dev/shm/textg_$session.txt"
23 | askg="/dev/shm/askg_$session.txt"
24 | tradg="/dev/shm/tradg_$session.txt"
25 | codeg="/dev/shm/codeg_$session.txt"
26 |
27 | subg="/dev/shm/subg_$session.srt"
28 | input=""
29 | output=""
30 | tmp=""
31 |
32 | if ! type t2c 2>/dev/null 1>&2;
33 | then
34 | t2c ()
35 | {
36 |
37 |
38 | if ! command -v docker --version 2>/dev/null 1>&2;
39 | then
40 | echo " Gum docker is not installed on your system. Install it: https://docs.docker.com/engine/install and re-try" >&2;
41 | echo "o-sgpc is disabled" >&2;
42 | elif ! command -v gum --version 2>/dev/null 1>&2;
43 | then
44 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
45 | echo "o-sgpc is disabled" >&2;
46 | else
47 | if ! type o-sgpc 2>/dev/null 1>&2;
48 | then
49 | o-sgpc ()
50 | {
51 |
52 |
53 | local input="$1";
54 | #takes function "textg" parmaeter as input or if empty prompts for input
55 | local input=${input:-$(echo $(gum input --char-limit=4000 --placeholder="Type something here, just askg me!" --width="$(($COLUMNS-5))" --header="I'm an AI, use me wisely!" --header.italic --header.border="rounded" --header.foreground="50" ) )};
56 | if [ -z "$input" ];
57 | then
58 | echo "No input" >&2;
59 | return 1;
60 | fi
61 |
62 | echo $input > $askg > /dev/null ;
63 |
64 | gum spin -s points --show-output --spinner.foreground="50" --title.bold --spinner.margin="0 1" --title "using Docker to interact with sgpc..." --\
65 | docker run --rm --env OPENAI_API_KEY -v gpt-cache:/tmp/shell_gpt ghcr.io/ther1d/shell_gpt --no-animation --code "$input" > "$codeg";
66 | gum confirm --negative="no" --affirmative="yes, let's read " "open pager to read subgtitles?" --timeout=15s --selected.foreground="0" --unselected.foreground="44" --selected.italic --unselected.italic --selected.background="50" --prompt.italic --prompt.margin="0 0 0 140" && gum pager --soft-wrap --border-foreground="86" --help.foreground="200" --show-line-numbers < o-sgpt.log ;
67 |
68 |
69 | local output=$(cat $codeg | tr -d '\n');
70 |
71 | if [ -z "$output" ];
72 | then
73 | echo '{{ Bold "Open.ai servers are probably down or unreachable, try again...}}' | gum format -t template >&2;
74 | return 1;
75 | fi
76 |
77 |
78 | gum style "INPUT: saved at $askg" "$input" "OUTPUT: saved at $codeg" "$output" "SESSION: $session" --foreground 15 --border-foreground 50 --border rounded --width="$(($COLUMNS -4))" --italic --margin "1 1" --padding "0 1";
79 | gum confirm --negative="no" --affirmative="yes, let's read!" "open pager to read output?" --timeout=15s --selected.foreground="0" --unselected.foreground="44" --selected.italic --unselected.italic --selected.background="50" --prompt.italic --prompt.margin="0 0 0 $(($COLUMNS -29))" \
80 | && gum pager --soft-wrap --border-foreground="86" --help.foreground="200" --show-line-numbers < $codeg;
81 | echo '{{ Bold "[+] sgpc OK" }}' | gum format -t template >&2;
82 |
83 | }
84 |
85 |
86 | else
87 | echo '{{ Color "50" "0" " o-sgpc is set on the system." }}' | gum format -t template >&2;
88 | fi
89 | fi
90 |
91 |
92 | o-sgpc "$1";
93 | }
94 | else
95 | echo '{{ Bold "t2c is set on the system" }}' | gum format -t template >&2;
96 | fi
97 |
--------------------------------------------------------------------------------
/i2i:
--------------------------------------------------------------------------------
1 | # Small but handy functions. For Personal use only.
2 | # Use it at your own risk!
3 | # Author: Gabriele Risso License: Apache 2.0
4 |
5 | #fboulnois_stable-diffusion-docker_ Run the official Stable Diffusion releases in a Docker container with txi2img, img2img, depth2img, pix2pix, upscale4x, and inpaint.
6 |
7 | filter=filter.rnn && wget -qO $filter https://raw.githubusercontent.com/GregorR/rnnoise-models/master/somnolent-hogwash-2018-09-01/sh.rnnn
8 |
9 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
10 |
11 |
12 |
13 |
14 | audiow="/dev/shm/audiow_$session.mp3"
15 | voicew="/dev/shm/voicew_$session.mp3"
16 | textw="/dev/shm/textw_$session.txt"
17 | tradw="/dev/shm/tradw_$session.txt"
18 | subw="/dev/shm/subw_$session.srt"
19 | imgw="/dev/shm/imgw_$session.png"
20 |
21 |
22 | voiceg="/dev/shm/vocieg_$session.mp3"
23 | audiog="/dev/shm/audiog_$session.mp3"
24 | textg="/dev/shm/textg_$session.txt"
25 | askg="/dev/shm/askg_$session.txt"
26 | subg="/dev/shm/subg_$session.srt"
27 | imgg="/dev/shm/imgg_$session.png"
28 |
29 |
30 | input=""
31 | output=""
32 | tmp=""
33 |
34 | #not tested
35 |
36 | if ! type i2i 2>/dev/null 1>&2;
37 | then
38 | i2i ()
39 | {
40 |
41 | if ! command -v docker --version 2>/dev/null 1>&2;
42 | then
43 | echo " docker is not installed on your system. Install it: https://docs.docker.com/engine/install and re-try" >&2;
44 | echo "sdimgi is disabled" >&2;
45 | elif ! command -v gum --version 2>/dev/null 1>&2;
46 | then
47 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
48 | echo "sdimgi is disabled" >&2;
49 | else
50 | if ! type sdimgi 2>/dev/null 1>&2;
51 | then
52 |
53 | echo '{{ Bold "[*] session: '$session' " }}' | gum format -t template >&2;
54 |
55 | sdimgi ()
56 | {
57 |
58 |
59 | echo '{{ Bold "[!] i2i started" }}' | gum format -t template >&2;
60 |
61 | local newest_filet=$(stat -c '%Y %n' /dev/shm/*.txt | sort -nr | head -n1 | cut -d' ' -f2);
62 |
63 | local inputt="$1";
64 | [ -f $newest_file ] && local inputt=${inputt:-$(echo $newest_file)} || local inputt=${inputt:-$(echo $(echo $(gum input --char-limit=4000 --placeholder="Type something here, just ask me!" --width="$(($COLUMNS-5))" --header="I'm an AI use me wisely!" --header.italic --header.border="rounded" --header.foreground="50" ))};
65 |
66 | local inputv="$2";
67 | local $newest_filev=$(stat -c '%Y %n' $PWD/output/*.png | sort -nr | head -n1 | cut -d' ' -f2);
68 | [ -f $newest_filev ] && local inputv=${inputv:-$(echo $newest_filev)} || local inputv=${inputv:-$(echo $(gum file $PWD))};
69 |
70 | echo '{{ Bold "[!] most recent possible prompt --> '$newestt_file'" }}' | gum format -t template >&2;
71 | echo '{{ Bold "[!] most recent image --> '$newestv_file'" }}' | gum format -t template >&2;
72 |
73 | if [ -z "$inputv" ] || [ -z "$inputt" ]; #check that text and voice are set
74 | then
75 | echo "bad inputs" >&2;
76 | return 1;
77 | fi
78 |
79 | echo $input > $askg >&2;
80 |
81 | gum spin -s points --show-output --spinner.foreground="50" --title.bold --spinner.margin="0 1" --title "using Docker to interact with stable diffusion..." --\
82 | ./build.sh run --image "$inputv" "$inputt"; #https://github.com/fboulnois/stable-diffusion-docker#huggingface-token
83 |
84 | local output=$(stat -c '%Y %n' $PWD/output/*.png | sort -nr | head -n1 | cut -d' ' -f2);
85 |
86 |
87 | if [ -z "$output" ];
88 | then
89 | echo '{{ Bold "someting went wrong, check https://github.com/fboulnois/stable-diffusion-docker and try again...' | gum format -t template >&2;
90 | return 1;
91 | fi
92 |
93 | gum style "INPUT: saved $askg" "$input" "OUTPUT: image saved at $output" "SESSION: $session" --foreground 15 --border-foreground 50 --border rounded --width="$(($COLUMNS -4))" --italic --margin "1 1" --padding "0 1";
94 |
95 |
96 | echo '{{ Bold "[+] sdimg started" }}' | gum format -t template >&2;
97 | }
98 | else
99 | echo '{{ Color "50" "0" " i2i-sdimgi is set on the system." }}' | gum format -t template >&2;
100 | fi
101 | fi
102 |
103 |
104 | i2i-sdimgi "$1";
105 | }
106 | else
107 | echo '{{ Bold "i2i is set on the system" }}' | gum format -t template >&2;
108 | fi
109 |
--------------------------------------------------------------------------------
/q2t:
--------------------------------------------------------------------------------
1 | # Small but handy functions. For Personal use only.
2 | # Use it at your own risk!
3 | # Author: Gabriele Risso License: Apache 2.0
4 |
5 | lang=${lang:-$(echo ${LANG:0:2})};
6 |
7 | filter=filter.rnn && wget -qO $filter https://raw.githubusercontent.com/GregorR/rnnoise-models/master/somnolent-hogwash-2018-09-01/sh.rnnn
8 |
9 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
10 |
11 |
12 |
13 |
14 | audiow="/dev/shm/audiow_$session.mp3"
15 | voicew="/dev/shm/voicew_$session.mp3"
16 | textw="/dev/shm/textw_$session.txt"
17 | tradw="/dev/shm/tradw_$session.txt"
18 | subw="/dev/shm/subw_$session.srt"
19 |
20 |
21 | voiceg="/dev/shm/vocieg_$session.mp3"
22 | audiog="/dev/shm/audiog_$session.mp3"
23 | textg="/dev/shm/textg_$session.txt"
24 | askg="/dev/shm/askg_$session.txt"
25 | subg="/dev/shm/subg_$session.srt"
26 | input=""
27 | output=""
28 | tmp=""
29 |
30 | if ! type q2t 2>/dev/null 1>&2;
31 | then
32 | q2t ()
33 | {
34 |
35 | if ! command -v docker --version 2>/dev/null 1>&2;
36 | then
37 | echo " Gum docker is not installed on your system. Install it: https://docs.docker.com/engine/install and re-try" >&2;
38 | echo "q2t-sgpt is disabled" >&2;
39 | elif ! command -v gum --version 2>/dev/null 1>&2;
40 | then
41 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
42 | else
43 | if ! type q2t-sgpt 2>/dev/null 1>&2;
44 | then
45 |
46 | echo '{{ Bold "[*] language: '$lang' " }}' | gum format -t template >&2;
47 | echo '{{ Bold "[*] session: '$session' " }}' | gum format -t template >&2;
48 |
49 | q2t-sgpt ()
50 | {
51 |
52 |
53 | echo '{{ Bold "[!] sgpt started" }}' | gum format -t template >&2;
54 |
55 |
56 |
57 | local input="$1";
58 | #takes function input or if empty askgs for inputs
59 | local input=${input:-$(echo $(gum input --char-limit=4000 --placeholder="Type something here, just askg me!" --width="$(($COLUMNS-5))" --header="I'm an AI use me wisely!" --header.italic --header.border="rounded" --header.foreground="50" ) )};
60 |
61 | if [ -z "$input" ];
62 | then
63 | echo "No input" >&2;
64 | return 1;
65 | fi
66 |
67 | echo $input > $askg >&2;
68 |
69 | gum spin -s points --show-output --spinner.foreground="50" --title.bold --spinner.margin="0 1" --title "using Docker to interact with sgpt..." --\
70 | docker run --rm --env OPENAI_API_KEY -v gpt-cache:/tmp/shell_gpt ghcr.io/ther1d/shell_gpt --no-animation --chat "$session" "$input" > "$textg";
71 |
72 | local output=$(cat $textg | tr -d '\n') >&2;
73 |
74 | if [ -z "$output" ];
75 | then
76 | echo '{{ Bold "Open.ai servers are probably down or unreachable, try again...' | gum format -t template >&2;
77 | return 1;
78 | fi
79 |
80 | gum style "INPUT: saved at $askg" "$input" "OUTPUT: saved at $textg" "$output" "SESSION: $session" --foreground 15 --border-foreground 50 --border rounded --width="$(($COLUMNS -4))" --italic --margin "1 1" --padding "0 1";
81 | gum confirm --negative="no" --affirmative="yes, let's read!" "open pager to read output?" --timeout=15s --selected.foreground="0" --unselected.foreground="44" --selected.italic --unselected.italic --selected.background="50" --prompt.italic --prompt.margin="0 0 0 $(($COLUMNS -29))" \
82 | && gum pager --soft-wrap --border-foreground="86" --help.foreground="200" --show-line-numbers < $textg;
83 |
84 | echo '{{ Bold "[+] sgpt OK" }}' | gum format -t template >&2;
85 |
86 |
87 |
88 | CHOICE=$(gum choose --item.foreground 250 "edit function sourcecode" "edit output text in glow" "edit input text in glow" "help" "contribute to aiyu");
89 | [[ "$CHOICE" == "edit function sourcecode" ]] && $EDITOR $(gum filter --value="q2t" --height=9);
90 | [[ "$CHOICE" == "edit output text in glow" ]] && cp $textg "${textw::-4}.md" && glow "/dev/shm/";
91 | [[ "$CHOICE" == "edit input text in glow" ]] && cp $textg "${textg::-4}.md" && glow "/dev/shm/";
92 | [[ "$CHOICE" == "help" ]] && glow -p README.md;
93 | [[ "$CHOICE" == "contribute to aiyu" ]] && echo "Great! I thought so, thank you for making $(gum style --bold "aiyu") is the best! leave a $(gum style --bold "star") if you like this. Go to: https://github.com/GabrieleRisso/aiyu";
94 |
95 |
96 | }
97 | else
98 | echo '{{ Color "50" "0" " q2t-sgpt is set on the system." }}' | gum format -t template >&2;
99 | fi
100 | fi
101 |
102 |
103 |
104 | q2t-sgpt "$1";
105 | }
106 | else
107 | echo '{{ Bold "q2t is set on the system" }}' | gum format -t template >&2;
108 | fi
109 |
--------------------------------------------------------------------------------
/s2s:
--------------------------------------------------------------------------------
1 |
2 | # Small but handy functions. For Personal use only.
3 | # Use it at your own risk!
4 | # Author: Gabriele Risso License: Apache 2.0
5 |
6 | #lang=${lang:-$(echo ${LANG:0:2})};
7 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
8 |
9 | subg="/dev/shm/subg_$session.txt"
10 | #textg="/dev/shm/textg_$session.txt"
11 | tradg="/dev/shm/tradg_$session.txt"
12 |
13 |
14 | if ! type s2s 2>/dev/null 1>&2;
15 | then
16 | s2s ()
17 | {
18 |
19 | if ! command -v docker --version 2>/dev/null 1>&2;
20 | then
21 | echo "trad is not installed on your system. https://github.com/soimort/translate-shell " >&2;
22 | echo "s2s-ttrans is disabled" >&2;
23 | elif ! command -v gum --version 2>/dev/null 1>&2;
24 | then
25 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
26 | else
27 | if ! type s2s-ttrans 2>/dev/null 1>&2;
28 | then
29 | s2s-ttrans ()
30 | {
31 |
32 | if [ -z ${OPENAI_API_KEY+x} ]; then echo '{{ Bold "[!] OPENAI_API_KEY not set! type: export OPENAI_API_KEY=\"your-key-here\" " }}' | gum format -t template >&2; return 1; fi
33 |
34 | echo '{{ Bold "[!] traduction started" }}' | gum format -t template >&2;
35 |
36 | local start=$SECONDS;
37 | local input="$2";
38 |
39 | local newest_file="";
40 | newest_file=$(find /dev/shm/ -type f -cmin -1 -size +0 -regextype sed -regex ".*\(t\|s\)*.\(txt\|srt\)" -printf "%T@ %p\n" 2>/dev/null | sort -n | tail -1 | awk '{print $2}');
41 | if [ -n "$newest_file" ]; then
42 | echo '{{ Bold "[!] most recent subtitle file --> '$newest_file'" }}' | gum format -t template >&2;
43 | local input=${input:-$(echo $newest_file)};
44 | else
45 | echo '{{ Bold "[+] Input prompt" }}' | gum format -t template >&2;
46 | local input=${input:-$(echo $(gum input --char-limit=4000 --placeholder="Type something here, just ask me!" --width="$(($COLUMNS-5))" ) )};
47 | fi
48 |
49 | local output="$tradg";
50 |
51 | local langto="$1";
52 | local langto=${langto:-$(echo "en")};
53 | local langfrom=${langfrom:-$(echo "auto")}; #sould autodetect language
54 |
55 | gum style "input subtitle: $input" "language from: $langfrom" "output: $output" "language to: $langto" "SESSION: $session" --foreground 15 --border-foreground 50 --border rounded --width="$(($COLUMNS -4))" --italic --margin "1 1" --padding "0 1";
56 |
57 | local intrad="";
58 | intrad=$(<"$input");
59 | echo $intrad > $subg >&2;
60 |
61 | #------------------------------------------------------------#
62 | #using https://github.com/soimort/translate-shell
63 | gum spin --spinner points --show-output --spinner.foreground="50" --title.bold --spinner.margin="0 1" --title "using trad for translation generation..." -- sleep 2
64 | docker run --rm -it soimort/translate-shell -shell -brief -w 10 :"$langto" "$intrad" | tail -n +3 > $output;
65 | #------------------------------------------------------------#
66 |
67 | # prints to terminal
68 | echo '{{ Bold "[t] completed in '$((SECONDS-start))' seconds" }}' | gum format -t template >&2;
69 |
70 | gum confirm --negative="no" --affirmative="yes, let's read!" "open pager to read translation?" --timeout=15s --selected.foreground="0" --unselected.foreground="44" --selected.italic --unselected.italic --selected.background="50" --prompt.italic --prompt.margin="0 0 0 $(($COLUMNS -29))" \
71 | && gum pager --soft-wrap --border-foreground="86" --help.foreground="200" --show-line-numbers < $output;
72 |
73 | echo '{{ Bold "[+] translation OK" }}' | gum format -t template >&2;
74 | echo '{{ Bold "[?] What now? press ESC to exit." }}' | gum format -t template >&2;
75 | echo ' ' >&2;
76 |
77 |
78 | while read -r -n1 key
79 | do
80 | # if input == ESC key
81 | if [[ $key == $'\e' ]];
82 | then
83 | break;
84 | fi
85 |
86 | CHOICE=$(gum choose --item.foreground 250 "edit function sourcecode" "edit output translation in glow" "edit input subtitle in glow" "help" "contribute to aiyu");
87 | [[ "$CHOICE" == "edit function sourcecode" ]] && $EDITOR $(gum filter --value="s2s" --height=18);
88 | [[ "$CHOICE" == "edit output translation in glow" ]] && cp $tradg "${tradg::-4}.md" && glow "/dev/shm/";
89 | [[ "$CHOICE" == "edit input subtitle in glow" ]] && cp $input "${input::-4}.md" && glow "/dev/shm/";
90 | [[ "$CHOICE" == "help" ]] && glow -p README.md;
91 | [[ "$CHOICE" == "contribute to aiyu" ]] && echo "Great! I thought so, thank you for making $(gum style --bold "aiyu") is the best! leave a $(gum style --bold "star") if you like this. Go to: https://github.com/GabrieleRisso/aiyu";
92 |
93 | done;
94 |
95 | }
96 | else
97 | echo "s2s-ttrans is set on the system.To use it: \"s2s-ttrans lang file.txt \" " >&2;
98 | fi
99 | fi
100 |
101 | s2s-ttrans "$1" "$2";
102 | #s2s-dtrans "$1" "$2";
103 | }
104 | else
105 | echo '{{ Bold "s2s is set on the system" }}' | gum format -t template >&2;
106 | fi
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/p2t:
--------------------------------------------------------------------------------
1 | # Small but handy functions. For Personal use only.
2 | # Use it at your own risk!
3 | # Author: Gabriele Risso License: Apache 2.0
4 |
5 |
6 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
7 |
8 | promptg="/dev/shm/promptg_$session.txt"
9 | textg="/dev/shm/textg_$session.txt"
10 |
11 |
12 | input=""
13 | output=""
14 |
15 |
16 | if ! type p2t 2>/dev/null 1>&2;
17 | then
18 | p2t ()
19 | {
20 |
21 | if ! command -v docker --version 2>/dev/null 1>&2;
22 | then
23 | echo " Gum docker is not installed on your system. Install it: https://docs.docker.com/engine/install and re-try" >&2;
24 | echo "p2t-sgpt is disabled" >&2;
25 | elif ! command -v gum --version 2>/dev/null 1>&2;
26 | then
27 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
28 | else
29 | if ! type p2t-sgpt 2>/dev/null 1>&2;
30 | then
31 |
32 | echo '{{ Bold "[*] session: '$session' " }}' | gum format -t template >&2;
33 |
34 | p2t-sgpt ()
35 | {
36 |
37 | if [ -z ${OPENAI_API_KEY+x} ]; then echo '{{ Bold "[!] OPENAI_API_KEY not set! type: export OPENAI_API_KEY=\"your-key-here\" " }}' | gum format -t template >&2; return 1; fi
38 |
39 | echo '{{ Bold "[!] sgpt started" }}' | gum format -t template >&2;
40 |
41 | local start=$SECONDS;
42 |
43 | local input="$1";
44 | local output="";
45 |
46 | #select the lastly created file.txt (1 minute old) located in /dev/shm/ that macthces t or s as a first char fo the file name OR input prompt directly
47 | local newest_file="";
48 | newest_file=$(find /dev/shm/ -type f -cmin -1 -size +0 -regextype sed -regex ".*\(t\|s\)*.txt" -printf "%T@ %p\n" 2>/dev/null | sort -n | tail -1 | awk '{print $2}');
49 | if [ -n "$newest_file" ]; then
50 | echo '{{ Bold "[!] most recent text file --> '$newest_file'" }}' | gum format -t template >&2;
51 | local input=${input:-$(echo $newest_file)};
52 | else
53 | echo '{{ Bold "[+] Input prompt" }}' | gum format -t template >&2;
54 | local input=${input:-$(echo $(gum input --char-limit=4000 --placeholder="Type something here, just ask me!" --width="$(($COLUMNS-5))" ) )};
55 | fi
56 |
57 |
58 | #-------------------------------------x
59 | gum spin -s points --show-output --spinner.foreground="50" --title.bold --spinner.margin="0 1" --title "using Docker to interact with sgpt..." --\
60 | docker run --rm --env OPENAI_API_KEY -v gpt-cache:/tmp/shell_gpt ghcr.io/ther1d/shell_gpt --no-animation --chat "$session" "$input" > "$textg";
61 | #-------------------------------------x
62 |
63 | echo '{{ Bold "[t] completed in '$((SECONDS-start))' seconds" }}' | gum format -t template >&2;
64 |
65 | echo $input > $promptg >&2;
66 |
67 | output=$(cat $textg | tr -d '\n') >&2;
68 |
69 | if [ -z "$output" ];
70 | then
71 | echo '{{ Bold "Openai key could be expired or Servers are probably down or unreachable, try again..." ' | gum format -t template >&2;
72 | return 1;
73 | fi
74 |
75 | gum style "INPUT: saved at $promptg" " " "$input" "OUTPUT: saved at $textg" " " "$output" "SESSION: $session" --foreground 15 --border-foreground 50 --border rounded --width="$(($COLUMNS -4))" --italic --margin "1 1" --padding "0 1";
76 | gum confirm --negative="no" --affirmative="yes, let's read!" "open pager to read output?" --timeout=15s --selected.foreground="0" --unselected.foreground="44" --selected.italic --unselected.italic --selected.background="50" --prompt.italic --prompt.margin="0 0 0 $(($COLUMNS -29))" \
77 | && gum pager --border-foreground="86" --help.foreground="200" --show-line-numbers < $textg;
78 |
79 | echo '{{ Bold "[+] sgpt OK" }}' | gum format -t template >&2;
80 |
81 | echo '{{ Bold "[?] What now? press ESC to exit." }}' | gum format -t template >&2;
82 | echo ' ' >&2;
83 |
84 | while read -r -n1 key
85 | do
86 | # if input == ESC key
87 | if [[ $key == $'\e' ]];
88 | then
89 | break;
90 | fi
91 |
92 | CHOICE=$(gum choose --item.foreground 250 "edit output text in glow" "edit input text in glow" "help" "contribute to aiyu");
93 | [[ "$CHOICE" == "edit output text in glow" ]] && cp $textg "${textg::-4}.md" && glow "/dev/shm/";
94 | [[ "$CHOICE" == "edit input text in glow" ]] && cp $promptg "${promptg::-4}.md" && glow "/dev/shm/";
95 | [[ "$CHOICE" == "help" ]] && glow -p README.md;
96 | [[ "$CHOICE" == "contribute to aiyu" ]] && echo "Great! I thought so, thank you. Leave a $(gum style --bold "star") if you like $(gum style --bold "aiyu"). Go to: https://github.com/GabrieleRisso/aiyu";
97 |
98 | done;
99 |
100 | }
101 | else
102 | echo '{{ Bold "p2t-sgpt is set on the system." }}' | gum format -t template >&2;
103 | fi
104 | fi
105 |
106 | p2t-sgpt "$1";
107 | }
108 | else
109 | echo '{{ Bold "p2t is set on the system" }}' | gum format -t template >&2;
110 | fi
--------------------------------------------------------------------------------
/a2s:
--------------------------------------------------------------------------------
1 | # Small but handy functions. For Personal use only.
2 | # Use it at your own risk!
3 | # Author: Gabriele Risso License: Apache 2.0
4 |
5 |
6 | lang=${lang:-$(echo ${LANG:0:2})};
7 |
8 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
9 |
10 | audiow="/dev/shm/audiow_$session.mp3"
11 | voicew="/dev/shm/voicew_$session.mp3"
12 | subw="/dev/shm/subw_$session.srt"
13 |
14 | voiceg="/dev/shm/voiceg_$session.mp3"
15 | audiog="/dev/shm/audiog_$session.mp3"
16 | subg="/dev/shm/subg_$session.srt"
17 |
18 |
19 | input=""
20 | output=""
21 |
22 |
23 | if ! type a2s 2>/dev/null 1>&2;
24 | then
25 | a2s ()
26 | {
27 | if ! command -v whisper-ctranslate2 2>/dev/null 1>&2;
28 | then
29 | echo "whisper-ctranslate2 is not installed on your system. Install it: pip install -U whisper-ctranslate2" >&2;
30 | echo "o-whis is disabled" >&2;
31 | elif ! command -v gum --version 2>/dev/null 1>&2;
32 | then
33 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
34 | else
35 | if ! type a2s-whisp 2>/dev/null 1>&2;
36 | then
37 |
38 | echo '{{ Bold "[*] session: '$session' " }}' | gum format -t template >&2;
39 |
40 | a2s-whisp ()
41 | {
42 |
43 | #set -euo pipefail;
44 |
45 | echo '{{ Bold "[!] whisper subtitles started" }}' | gum format -t template >&2;
46 |
47 | if [ -z ${OPENAI_API_KEY+x} ]; then echo '{{ Bold "[!] OPENAI_API_KEY not set! type: export OPENAI_API_KEY=\"your-key-here\" " }}' | gum format -t template >&2; return 1; fi
48 |
49 | local start=$SECONDS;
50 |
51 | local formatsub=${formatsub:-$(echo "srt")};
52 | local model=${model:-$(echo "medium")};
53 | #if input text exis then set it as input, if not select it
54 |
55 | local input="$1";
56 | #1 is te counter time. 0 to achive full flow test
57 | #select the lastly created file.mp3 (1 minute old) located in /dev/shm/ OR select a local .mp3 file
58 | local newest_file="";
59 | local newest_file=$(find /dev/shm/ -cmin -1 -type f -name "*.mp3" -printf "%T@ %p\n" 2>/dev/null | sort -n | tail -1 | awk '{print $2}');
60 | if [ -n "$newest_file" ]; then
61 | echo '{{ Bold "[!] most recent file --> '$newest_file'" }}' | gum format -t template >&2;
62 | local input=${input:-$(echo $newest_file)};
63 | else
64 | echo '{{ Bold "[+] Select a mp3 file. Use keyboard arrows < > to traverse directories, up or down arrows to move in the directory." }}' | gum format -t template >&2;
65 | local input=$(gum file $PWD);
66 | fi
67 |
68 | #output definition
69 | local output="$2";
70 | local output=${output:-$(echo $subw)};
71 |
72 | gum style "INPUT audio located at: $input" "INput audio language: auto" "OUTPUT subtitles saved at $output" "OUTput language: auto" "SESSION: $session" --foreground 15 --border-foreground 50 --border rounded --width="$(($COLUMNS -4))" --italic --margin "1 1" --padding "0 1";
73 |
74 | gum spin -s points --show-output --spinner.foreground="50" --title.bold --spinner.margin="0 1" --title "using Whisper for subtitles creation... this can take a short while" --\
75 | whisper-ctranslate2 $input --output_format $formatsub --task transcribe --compute_type int8 --output_dir /dev/shm/ ;
76 | #choose best model
77 | echo '{{ Bold "[t] completed in '$((SECONDS-start))' seconds" }}' | gum format -t template >&2;
78 |
79 | #rename subtitle file to the output name
80 | local tmpsub=$(basename $input);
81 | mv "/dev/shm/${tmpsub%.*}.$formatsub" $output;
82 |
83 | gum confirm --negative="no" --affirmative="yes, let's read!" "open pager to read subtitles?" --timeout=15s --selected.foreground="0" --unselected.foreground="44" --selected.italic --unselected.italic --selected.background="50" --prompt.italic --prompt.margin="0 0 0 $(($COLUMNS -29))" \
84 | && gum pager --soft-wrap --border-foreground="86" --help.foreground="200" --show-line-numbers < $output;
85 |
86 | echo '{{ Bold "[t] completed in '$((SECONDS-start))' seconds" }}' | gum format -t template >&2;
87 | echo '{{ Bold "[+] subtitles OK" }}' | gum format -t template >&2;
88 |
89 | echo '{{ Bold "[?] What now? press ESC to exit." }}' | gum format -t template >&2;
90 | echo ' ' >&2;
91 |
92 | CHOICE=$(gum choose --item.foreground 250 "edit function sourcecode" "edit output subtitles in glow" "play input audio" "help" "contribute to aiyu");
93 | [[ "$CHOICE" == "edit function sourcecode" ]] && $EDITOR $(gum filter --value="a2s" --height=9);
94 | [[ "$CHOICE" == "edit output subtitles in glow" ]] && cp $subw "${subw::-4}.md" && glow "/dev/shm/";
95 | [[ "$CHOICE" == "play input audio" ]] && ffplay -nodisp -autoexit -loglevel fatal $input;
96 | [[ "$CHOICE" == "help" ]] && glow -p README.md;
97 | [[ "$CHOICE" == "contribute to aiyu" ]] && echo "Great! I thought so, thank you for making $(gum style --bold "aiyu") is the best! leave a $(gum style --bold "star") if you like this. Go to: https://github.com/GabrieleRisso/aiyu";
98 |
99 | }
100 | else
101 | echo "a2s-whisp is set on the system. To use it: o-a2s \"input.mp3\" \"output.mp3\" " >&2;
102 | fi
103 | fi
104 |
105 | a2s-whisp "$1" "$2";
106 |
107 | }
108 | else
109 | echo '{{ Bold "a2s is set on the system" }}' | gum format -t template >&2;
110 | fi
111 |
--------------------------------------------------------------------------------
/a2t:
--------------------------------------------------------------------------------
1 | # Small but handy functions. For Personal use only.
2 | # Use it at your own risk!
3 | # Author: Gabriele Risso License: Apache 2.0
4 |
5 |
6 | #lang=${lang:-$(echo ${LANG:0:2})};
7 |
8 | session=${session:-$(echo "$(wget -qO - http://frightanic.com/goodies_content/docker-names.php)-$(date '+%Y-%m-%d-%H')" )};
9 |
10 |
11 | textw="/dev/shm/textw_$session.txt"
12 | audiow="/dev/shm/audiow_$session.mp3"
13 |
14 |
15 | if ! type a2t 2>/dev/null 1>&2;
16 | then
17 | a2t ()
18 | {
19 | if ! command -v whisper-ctranslate2 2>/dev/null 1>&2;
20 | then
21 | echo "whisper-ctranslate2 is not installed on your system. Install it: pip install -U whisper-ctranslate2" >&2;
22 | echo "if it's your first time whisper is going to install a medium sized model (2.85 GB)"
23 | echo "a2t is disabled" >&2;
24 | elif ! command -v gum --version 2>/dev/null 1>&2;
25 | then
26 | echo " gum is not installed on your system. Install it: https://github.com/charmbracelet/gum#installation and re-try" >&2;
27 | else
28 | if ! type a2t-whisp 2>/dev/null 1>&2;
29 | then
30 | a2t-whisp ()
31 | {
32 |
33 | if [ -z ${OPENAI_API_KEY+x} ]; then echo '{{ Bold "[!] OPENAI_API_KEY not set! type: export OPENAI_API_KEY=\"your-key-here\" " }}' | gum format -t template >&2; return 1; fi
34 |
35 | echo '{{ Bold "[*] session: '$session' " }}' | gum format -t template >&2;
36 | echo '{{ Bold "[!] whisper subtitles started" }}' | gum format -t template >&2;
37 |
38 | local start=$SECONDS;
39 | local formatsub=${formatsub:-$(echo "txt")};
40 | local model=${model:-$(echo "medium")};
41 | #if input text exis then set it as input, if not select it
42 | local input="$1";
43 |
44 | #select the lastly created file.mp3 (1 minute old) located in /dev/shm/ OR select a local .mp3 file
45 | local newest_file="";
46 | newest_file=$(find /dev/shm/ -type f -cmin -1 -size +0 -regextype sed -regex ".*\(a\|v\)*.mp3" -printf "%T@ %p\n" 2>/dev/null | sort -n | tail -1 | awk '{print $2}');
47 | if [ -n "$newest_file" ]; then
48 | echo '{{ Bold "[!] most recent file --> '$newest_file'" }}' | gum format -t template >&2;
49 | input=${input:-$(echo $newest_file)};
50 | else
51 | echo '{{ Bold "[+] Select a mp3 file. Use keyboard arrows < > to traverse directories, up or down arrows to move in the directory." }}' | gum format -t template >&2;
52 | input=$(gum file $PWD);
53 | fi
54 |
55 | cp $input $audiow;
56 |
57 | #output definition
58 | local output="$2";
59 | local output=${output:-$(echo $textw)};
60 | #local tmpsrt=$(basename $subw);
61 | #local tmptxt=$(basename $output);
62 |
63 | gum style "INPUT audio located at: $input" "INput audio language: auto" "OUTPUT text saved at $output" "OUTput language: auto" "SESSION: $session" --foreground 15 --border-foreground 50 --border rounded --width="$(($COLUMNS -4))" --italic --margin "1 1" --padding "0 1";
64 |
65 | gum spin -s points --show-output --spinner.foreground="50" --title.bold --spinner.margin="0 1" --title "using Whisper for subtitles creation... this can take a short while" --\
66 | whisper-ctranslate2 $input --output_format $formatsub --task transcribe --compute_type int8 --output_dir /dev/shm/ ;
67 | #choose best model
68 | echo '{{ Bold "[t] completed in '$((SECONDS-start))' seconds" }}' | gum format -t template >&2;
69 |
70 | #rename subtitle file to the output name
71 | local namesrt="";
72 | namesrt=$(basename $input);
73 | mv "/dev/shm/${namesrt%.*}.$formatsub" "$textw";
74 |
75 | # subtitle to text: https://github.com/yumstar/srt2text/blob/main/srt2text.py
76 |
77 | #context
78 | gum confirm --negative="no" --affirmative="yes, let's read!" "open pager to read text?" --timeout=15s --selected.foreground="0" --unselected.foreground="44" --selected.italic --unselected.italic --selected.background="50" --prompt.italic --prompt.margin="0 0 0 $(($COLUMNS -29))" \
79 | && gum pager --soft-wrap --border-foreground="86" --help.foreground="200" --show-line-numbers < $output;
80 | echo '{{ Bold "[+] subtitles OK" }}' | gum format -t template >&2;
81 |
82 | echo '{{ Bold "[?] What now? press ESC to exit." }}' | gum format -t template >&2;
83 | echo ' ' >&2;
84 |
85 | while read -r -n1 key
86 | do
87 | # if input == ESC key
88 | if [[ $key == $'\e' ]];
89 | then
90 | break;
91 | fi
92 |
93 | CHOICE=$(gum choose --item.foreground 250 "edit function sourcecode" "edit output text in glow" "play input audio" "help" "contribute to aiyu");
94 | [[ "$CHOICE" == "edit function sourcecode" ]] && $EDITOR $(gum filter --value="a2t" --height=9);
95 | [[ "$CHOICE" == "edit output text in glow" ]] && cp $textw "${textw::-4}.md" && glow "/dev/shm/";
96 | [[ "$CHOICE" == "play input audio" ]] && ffplay -nodisp -autoexit -loglevel fatal $input;
97 | [[ "$CHOICE" == "help" ]] && glow -p README.md;
98 | [[ "$CHOICE" == "contribute to aiyu" ]] && echo "Great! I thought so, thank you for making $(gum style --bold "aiyu") is the best! leave a $(gum style --bold "star") if you like this. Go to: https://github.com/GabrieleRisso/aiyu";
99 |
100 | done;
101 |
102 | }
103 |
104 | else
105 | echo "a2t is set on the system. To use it: a2t \"input.mp3\" \"output.mp3\" " >&2;
106 | fi
107 | fi
108 |
109 | a2t-whisp "$1" "$2";
110 |
111 | }
112 | else
113 | echo '{{ Bold "a2t is set on the system" }}' | gum format -t template >&2;
114 | fi
115 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Core shell functions for AI
2 |
3 | ## What is **AIyu**:
4 | In essence, the Aiyu Shell pipelines serve as the interweaving adhesive that binds the various AI components together - a technological superglue of sorts!
5 |
6 | **Aiyu** allows to build pipelines that easlily leverage the most exciting **ai** technologies using any laptop.
7 |
8 | #### example
9 |
10 | ###### input: audio in some language; output: audio in French
11 | ```
12 | m2a; a2a fr; a2sk
13 | ```
14 | Listen to your microphone and outputs an audio file (m2a), then use the previously created audio and translate it to French (a2a fr) and lastly plays the audio to your speaker (a2sk).
15 |
16 |
17 | ###### input: audio question in some language; output: audio GPT response in Italian
18 | ```
19 | m2a; a2p; p2a; a2a it
20 | ```
21 | Listen to your microphone and outputs an audio file (m2a), then use the created audio and transcribes it to textual prompt (a2p), use the prompt to query GPT3.5-turbo and produce an audio of the answare (p2a) and lastly, use the created audio and translate it to Italian (a2a it).
22 |
23 |
24 |
25 |
26 | Glossary of abbreviations
29 |
30 | ## Inputs and Outputs
31 |
32 | ```
33 | c -> code ex: sourcecode of a python program
34 | p -> prompt ex: "how can I escape the matrix?"
35 | t -> text ex: .txt file of a motivation letter
36 | s -> subtitle ex: .srt file of a movie subtitles
37 | a -> audio ex: .mp3 file of a recorded conference
38 | I/O: {sk -> speaker, m <- microphone}
39 | ```
40 | Concise pipelines (inputs2output)
65 |
66 | 🔹 Ask gpt and gtts answer to **speaker** (text2speaker) -> t2sk
67 | 🔹 Ask gpt and gtts answer to **audio** (text2audio) -> t2a
68 | 🔹 Ask gpt and produce specifically **code** (code2text) -> c2t
69 | 🔹 Take audio and produce text **transcript** (audio2text) -> a2t
70 | 🔹 Take audio and produce **subtitles** transcript (audio2subtitles) -> a2s
71 | 🔹 Prompt gpt and produce text (prompt2text) -> p2t
72 | 🔹 Take text and translate into text (text2text) -> t2tr
73 | 🔹 Take audio and **enhance quality** into audio (audio2audio) -> a2a
74 | 🔹 Take audio & text transcript and produce subtitles (audio+text2subtitles) -> at2s
75 | 🔹 Take text and stable diffusion produce **image** (text2image) -> t2i
76 |
77 |
78 |
79 |