-
Notifications
You must be signed in to change notification settings - Fork 0
/
transcribe.sh
executable file
·51 lines (43 loc) · 1.22 KB
/
transcribe.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Check if yt-dlp is installed
if ! command -v yt-dlp &> /dev/null
then
echo "yt-dlp could not be found. Please install yt-dlp."
exit 1
fi
# Check if ffmpeg is installed
if ! command -v ffmpeg &> /dev/null
then
echo "ffmpeg could not be found. Please install ffmpeg."
exit 1
fi
# Parse command-line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
-u|--url) url="$2"; shift ;;
-o|--output) output="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
# Check if required arguments are provided
if [ -z "$url" ] || [ -z "$output" ]; then
echo "Usage: $0 -u <url> -o <output>"
exit 1
fi
# Download audio from YouTube
yt-dlp -x \
--abort-on-error \
--extract-audio \
--audio-quality 7 \
--no-keep-video \
--no-update \
--ffmpeg-location $(which ffmpeg) \
--output "./audios/audio.%(ext)s" -k \
--audio-format flac "$url"
# Split the audio into 60-second chunks
ffmpeg -i audio.flac -f segment -segment_time 60 -c copy ./audios/chunk%03d.flac
for chunk in ./audios/chunk*.flac; do
make whisper ./audios/$chunk >> "$output"
done
# TODO: Pipe the transcription to ollama and summarize the results using the Modelfile.