feat(user/bkmpv2):Filter audio files by file extension
[BK-2020-03.git] / user / transcribe_whisper.sh
index 68756c74085f9fb88a65fc04effd328932940035..00dc3139add4422ec23629bb51dd89648aad90f8 100755 (executable)
@@ -1,8 +1,9 @@
 #!/bin/bash
 # Desc: Runs OpenAI Whisper on working directory media files
-# Usage: ./transcribe_whisper.sh 3
-# Input: arg1  CUDA graphics card number (zero-indexed)
-# Version: 0.1.0
+# Usage: ./transcribe_whisper.sh [dir] 3
+# Input: arg1  input dir
+#        arg2  CUDA graphics card number (zero-indexed)
+# Version: 0.4.0
 # Depends: whisper ( https://github.com/openai/whisper )
 
 # Find settings
@@ -52,11 +53,13 @@ find_flist() {
     must find "$1" -maxdepth "$fdepth" -type f -iregex "$firegex" -size +"$fsize";
 }; # print file list to stdout from dir with script parameters
 main() {
-    # Input: var:  fdepth   (find_flist) find depth
-    #        var:  firegex  (find_flist) pattern find iregex
-    #        var:  fsize    (find_flist) find size
-    cuda_num="$1";
-    dir_in="$(pwd)";
+    # Input: arg1: dir_in    input dir
+    #        arg2: cuda_num  cuda GPU index
+    #        var:  fdepth    (find_flist) find depth
+    #        var:  firegex   (find_flist) pattern find iregex
+    #        var:  fsize     (find_flist) find size
+    dir_in="$1";
+    cuda_num="$2";
     if ! checkInt "$cuda_num"; then die "FATAL:No graphics card selected."; fi;
     while read -r line; do
         echo "STATUS:Processing:$line" 1>&2;
@@ -86,7 +89,7 @@ main() {
                 echo "STATUS:$SECONDS:Finished:$line" 1>&2;
                 rm "$ftmp"; # remove .tmp file
             );
-    done < <(find_flist "$dir_in");
+    done < <(find_flist "$dir_in" | shuf);
 }; # main program
 export -f yell die must find_flist;