Skip to content

Commit ce82579

Browse files
committed
add binary
1 parent f39b3b1 commit ce82579

4 files changed

Lines changed: 72 additions & 8 deletions

File tree

bin/mp4grep

2.84 MB
Binary file not shown.

bin/mp4grep-convert

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
# Iterate through each input
4+
# If the input is a supported audio file, try to convert
5+
# If it's a directory, try to get all files from it
6+
7+
function is_audio_file ()
8+
{
9+
audiofile=$1
10+
IFS='.' read -r -a split_on_space <<< "$audiofile"
11+
extension=${split_on_space[-1]}
12+
13+
case "$extension" in
14+
mp3|mp4|ogg|webm|mov|wav|avi)
15+
echo 1;;
16+
*)
17+
echo 0;;
18+
esac
19+
20+
}
21+
22+
function extract_audio_from_dir
23+
{
24+
for file in "$1"/*
25+
do
26+
is_audio_test=$(is_audio_file $file)
27+
if [ $is_audio_test -eq 1 ]
28+
then
29+
audio_file_lst+=($file)
30+
fi
31+
done
32+
}
33+
34+
audio_file_lst=()
35+
for inp in $*
36+
do
37+
is_audio_test=$(is_audio_file $inp)
38+
if [ $is_audio_test -eq 1 ]
39+
then
40+
audio_file_lst+=($inp)
41+
elif [ -d "${inp}" ]
42+
then
43+
echo "${inp} is a directory, extracting audio files."
44+
extract_audio_from_dir $inp
45+
else
46+
echo "${inp} is not an audio file or directory. Doing nothing."
47+
fi
48+
49+
done
50+
51+
echo "Files that will be converted:"
52+
echo "-----------------------------"
53+
for audio in ${audio_file_lst[@]}
54+
do
55+
echo "${audio} -> ${audio}.wav"
56+
done
57+
echo "-----------------------------"
58+
59+
60+
for audio in ${audio_file_lst[@]}
61+
do
62+
ffmpeg -hide_banner -loglevel error -i "$audio" -acodec pcm_s16le -ac 1 -ar 16000 "${audio}.wav"
63+
done
64+

bin/mp4grep-libs/libvosk.so

23.8 MB
Binary file not shown.

mp4grep.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,11 @@ let do_search (args : search_params) =
480480
|> get_valid_audio_files_loud
481481
|> List.filter ignore_cached_files
482482
in
483+
484+
(if (List.length audiofiles_to_transcribe > 0) then begin
485+
transcribe_files audiofiles_to_transcribe;
486+
end);
483487

484-
transcribe_files audiofiles_to_transcribe;
485-
486488
let search_transcript (orig_search : string) (audio_file : string) =
487489
let file = get_transcript audio_file in
488490
let str_to_search = read_whole_file file in
@@ -491,12 +493,10 @@ let do_search (args : search_params) =
491493
|> String.trim
492494
in
493495

494-
495496
(* LOAD TIMESTAMPS INTO HASHTABLE *)
496-
497497
let tbl = get_byte_to_timestamp_table audio_file in
498498

499-
(* FIND ALL THE MATCHES AND PUT IN RESULT LIST *)
499+
(* FIND ALL THE MATCHES AND PUT IN RESULT LIST *)
500500
(* Str.search_forward/backward has side effect: *)
501501
(* The next call to Str.matched_string will return the matched string *)
502502
let last_match_reached = ref false in
@@ -521,7 +521,7 @@ let do_search (args : search_params) =
521521
(* Iterate backwards until words_after + 1 spaces are found *)
522522
let spaces_prior = ref 0 in
523523
let spaces_after = ref 0 in
524-
while ((!endpos < (String.length str_to_search))
524+
while ((!endpos < ((String.length str_to_search) - 1))
525525
&& (!spaces_after < (after + 1))) do
526526
endpos := !endpos + 1;
527527
if str_to_search.[!endpos] = ' ' then begin
@@ -534,13 +534,13 @@ let do_search (args : search_params) =
534534
&& (!spaces_prior < (before + 1))) do
535535
startpos := !startpos - 1;
536536
if str_to_search.[!startpos] = ' ' then begin
537-
spaces_prior := !spaces_prior + 1;
537+
spaces_prior := !spaces_prior + 1;
538538
end
539539
done;
540540

541541
(* Make sure that the starting position is always
542542
not a space, to index into the timestamps *)
543-
if str_to_search.[!startpos] = ' ' then begin
543+
if ((!startpos > 0) && (str_to_search.[!startpos] = ' ')) then begin
544544
startpos := !startpos + 1;
545545
end;
546546

0 commit comments

Comments
 (0)