transcribe-matrix-live

A fork for matrix-live transcription@home by fyyd.de
git clone git://archive.git.mtrnord.blog/MTRNord/transcribe-matrix-live.git
Log | Files | Refs | README

setup.sh (2521B)


      1 #!/bin/bash
      2 
      3 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
      4 cd $SCRIPT_DIR
      5 
      6 if [ -f ./trancribe.cfg ]
      7 	then
      8 		source "./trancribe.cfg"
      9 fi
     10 
     11 
     12 export LC_NUMERIC="en_US.UTF-8"
     13 
     14 # Check ffmpeg etc
     15 
     16 if ! command -v ffmpeg &> /dev/null
     17 then
     18 	echo "Can't find ffmpeg. Please install."
     19     exit
     20 fi
     21 
     22 if ! command -v git &> /dev/null
     23 then
     24 	echo "Can't find git. Please install."
     25     exit
     26 fi
     27 
     28 if ! command -v yt-dlp &> /dev/null
     29 then
     30 	echo "Can't find yt-dlp. Please install."
     31     exit
     32 fi
     33 
     34 if [ ! -f "whisper.cpp/whisper.cpp" ]
     35 	then
     36 		echo "downloading whisper.cpp"
     37 		git clone https://github.com/ggerganov/whisper.cpp	
     38 
     39 		echo "compiling whisper..."
     40 		cd whisper.cpp
     41 		WHISPER_CLBLAST=1 make -j
     42 
     43 		echo "downloading the model"
     44 		./models/download-ggml-model.sh medium	
     45 	else
     46 		cd whisper.cpp
     47 fi
     48 
     49 THREADS=0
     50 THREADS=`getconf _NPROCESSORS_ONLN`
     51 if [ $? -ne 0 ] 
     52 	then
     53 		THREADS=`getconf NPROCESSORS_ONLN`
     54 fi
     55 
     56 
     57 if [ $THREADS -eq 0 ]
     58 	then
     59 		echo -n "could not find number of threads. how many to use for transcription? (number or return to let whisper utilize cpu as guessed): "
     60 	else
     61 		echo -n "maximum of $THREADS threads found. how many to use for transcription? (number of threads or return for $THREADS) : "
     62 fi
     63 
     64 read inputthreads
     65 	
     66 if [ ! -z "$inputthreads" ]
     67 	then
     68 		echo "leer"
     69 		THREADS=$inputthreads
     70 fi		
     71 
     72 THREAD_OPT=""
     73 
     74 if [ "$THREADS" -ne 0 ]
     75 	then
     76 		THREAD_OPT=" -t $THREADS"
     77 fi
     78 
     79 START=`date +%s`
     80 
     81 echo -e "\nstarting test. this might take some minutes, please wait...\n"
     82 nice -n 18 ./main -m models/ggml-medium.bin $THREAD_OPT -l de -di ../test.wav 2>/dev/null
     83 
     84 if [ $? -ne 0 ]
     85 	then
     86 		echo "error transcribing. stopping"
     87 		
     88 fi
     89 
     90 
     91 DURATION=300
     92 END=`date +%s`
     93 TOOK=$(($END-$START))
     94 RATE=`echo "$DURATION/$TOOK" | bc -l`
     95 
     96 echo -e "------------------------------------------------------------------------------------------------------\n"
     97 
     98 echo -n "transcription took $TOOK seconds for 300 seconds audio. that is "
     99 printf "%.2f" $(echo "$DURATION/$TOOK" | bc -l)
    100 echo " times faster than realtime audio."
    101 
    102 if (( $(echo "$RATE < 1.5" |bc -l) ))
    103 	then
    104 		echo "that's very slow and you should maybe NOT transcribe with this computer."
    105 	elif (( $(echo "$RATE < 2" |bc -l) ))
    106 	then
    107 		echo "that's ok, but you should raise the number of threads if possible."
    108 	else
    109 		echo "that's great. let's transcribe some podcasts!"
    110 fi
    111 
    112 echo
    113 cd ..
    114 
    115 rm -f trancribe.cfg
    116 echo "THREADS=$THREADS" >> ./trancribe.cfg
    117 echo "PIDFILE=~/.trancribe-transcribe.pid" >> ./trancribe.cfg
    118 echo "MODEL=medium" >> ./trancribe.cfg