mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-19 04:37:51 +00:00
twitch.sh : various fixes and polishing
- check if streamlink is installed - fix audio chunking - change default threads to 4
This commit is contained in:
parent
9e5f3ddc16
commit
56822621a8
@ -1,15 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eo pipefail
|
#
|
||||||
# Transcribe audio livestream by feeding ffmpeg output to whisper.cpp at regular intervals
|
# Transcribe audio livestream by feeding ffmpeg output to whisper.cpp at regular intervals
|
||||||
# Idea by @semiformal-net
|
# Idea by @semiformal-net
|
||||||
# ref: https://github.com/ggerganov/whisper.cpp/issues/185
|
# ref: https://github.com/ggerganov/whisper.cpp/issues/185
|
||||||
#
|
#
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
url="http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/nonuk/sbr_low/ak/bbc_world_service.m3u8"
|
url="http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/nonuk/sbr_low/ak/bbc_world_service.m3u8"
|
||||||
fmt=aac # the audio format extension of the stream (TODO: auto detect)
|
fmt=aac # the audio format extension of the stream (TODO: auto detect)
|
||||||
step_s=30
|
step_s=30
|
||||||
model="base.en"
|
model="base.en"
|
||||||
|
|
||||||
|
check_requirements()
|
||||||
|
{
|
||||||
|
if ! command -v ./main &>/dev/null; then
|
||||||
|
echo "whisper.cpp main executable is required (make)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v ffmpeg &>/dev/null; then
|
||||||
|
echo "ffmpeg is required (https://ffmpeg.org)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_requirements
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "Usage: $0 stream_url [step_s] [model]"
|
echo "Usage: $0 stream_url [step_s] [model]"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Transcribe twitch.tv livestream by feeding audio input to whisper.cpp at regular intervals
|
||||||
|
# Thanks to @keyehzy
|
||||||
|
# ref: https://github.com/ggerganov/whisper.cpp/issues/209
|
||||||
|
#
|
||||||
|
# The script currently depends on the third-party tool "streamlink"
|
||||||
|
# On Mac OS, you can install it via "brew install streamlink"
|
||||||
|
#
|
||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
step=10
|
step=10
|
||||||
model=base.en
|
model=base.en
|
||||||
threads=1
|
threads=4
|
||||||
|
|
||||||
help()
|
help()
|
||||||
{
|
{
|
||||||
@ -18,6 +27,26 @@ help()
|
|||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_requirements()
|
||||||
|
{
|
||||||
|
if ! command -v ./main &>/dev/null; then
|
||||||
|
echo "whisper.cpp main executable is required (make)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v streamlink &>/dev/null; then
|
||||||
|
echo "streamlink is required (https://streamlink.github.io)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v ffmpeg &>/dev/null; then
|
||||||
|
echo "ffmpeg is required (https://ffmpeg.org)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_requirements
|
||||||
|
|
||||||
while getopts ":s:m:t:h" option; do
|
while getopts ":s:m:t:h" option; do
|
||||||
case $option in
|
case $option in
|
||||||
s)
|
s)
|
||||||
@ -58,6 +87,7 @@ set +e
|
|||||||
echo "Starting..."
|
echo "Starting..."
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
|
SECONDS=0
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
err=1
|
err=1
|
||||||
@ -72,7 +102,8 @@ do
|
|||||||
|
|
||||||
./main -t $threads -m ./models/ggml-$model.bin -f /tmp/whisper-live.wav --no-timestamps -otxt 2> /tmp/whispererr | tail -n 1
|
./main -t $threads -m ./models/ggml-$model.bin -f /tmp/whisper-live.wav --no-timestamps -otxt 2> /tmp/whispererr | tail -n 1
|
||||||
|
|
||||||
|
while [ $SECONDS -lt $((($i+1)*$step)) ]; do
|
||||||
sleep 1
|
sleep 1
|
||||||
|
done
|
||||||
((i=i+1))
|
((i=i+1))
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user