-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbashFunctions
22 lines (22 loc) · 1.22 KB
/
bashFunctions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
wh3()
{
echo "Run whisper using Python3.11 on a <audiofile> to transcribe it into text."
echo "Works with file types: mp3, mp4, mpeg, mpga, m4a, wav, and webm."
echo "The base model works with CPUs. Requires 1 minute per 6 minutes of audio."
echo "You may need to reset the path to the Python interpreter you want to use."
echo "Uses gawk to return one sentence per line to ease deleting whisper's rubbish."
echo "Uses sed to remove leading whitespace on each line."
echo "Uses TextMate to open the processed transcript."
echo "Uses the terminal app 'say' on Mac OS to announce when the transcribe is ready for you."
if [ $# -lt 1 ]; then
echo 1>&2 "$0: not enough arguments"
echo "Supply the mp3 file stem."
echo "Usage: wh3 230113_1649.mp3"
return 2
elif [ $# -gt 1 ]; then
echo 1>&2 "$0: too many arguments"
echo "Supply the mp3 file stem."
echo "Usage: wh3 230113_1649.map3"
fi
/usr/local/bin/python3.11 -c "import whisper;model = whisper.load_model('base');result = model.transcribe('$1');print(result['text'])" > $1.txt && ./replacem.py $1.txt && gawk '{gsub(/\./,"." ORS)} 1' $1.txtcorrected.txt > $1-clean.txt && sed 's/ //' $1-clean.txt > $1-ready.txt && mate $1.ready.txt && say 'Your audio transcription has finished.'
}