Skip to content

Commit

Permalink
Sync whisper.cpp + release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Nov 7, 2022
1 parent 0ab68e1 commit d5a7c79
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ default: build-submodule
.PHONY:
update-submodule:
# create a clean (maybe updated) copy of whisper.cpp
rsync ../../ggml.c Sources/whisper.cpp/
rsync ../../ggml.h Sources/whisper.cpp/
rsync ../../whisper.cpp Sources/whisper.cpp/
rsync ../../whisper.h Sources/whisper.cpp/
rsync ../../ggml.c Sources/whisper/
rsync ../../ggml.h Sources/whisper/
rsync ../../whisper.cpp Sources/whisper/
rsync ../../whisper.h Sources/whisper/include/

SOURCES := $(shell find Sources/ -print)
.build: $(SOURCES)
Expand All @@ -21,11 +21,11 @@ build: Package.swift .build

.PHONY:
publish: publish-trigger
echo " \
@echo " \
\n\
cd /path/to/whisper.cpp/bindings/ios\n\
git commit\n\
git tag 0.0.1\n\
git tag 1.0.0\n\
git push origin master --tags\n\
"

Expand Down
2 changes: 1 addition & 1 deletion Makefile-tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ update-submodule:
rsync ../../ggml.c Sources/whisper.cpp/
rsync ../../ggml.h Sources/whisper.cpp/
rsync ../../whisper.cpp Sources/whisper.cpp/
rsync ../../whisper.h Sources/whisper.cpp/
rsync ../../whisper.h Sources/whisper.cpp/include/

SOURCES := $(shell find Sources/ -print)
.build: $(SOURCES)
Expand Down
3 changes: 2 additions & 1 deletion Sources/whisper/include/whisper.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ extern "C" {

int n_threads;
int n_max_text_ctx;
int offset_ms;
int offset_ms; // start offset in ms
int duration_ms; // audio duration to process in ms

bool translate;
bool no_context;
Expand Down
11 changes: 7 additions & 4 deletions Sources/whisper/whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2339,6 +2339,7 @@ struct whisper_full_params whisper_full_default_params(enum whisper_sampling_str
/*.n_threads =*/ std::min(4, (int32_t) std::thread::hardware_concurrency()),
/*.n_max_text_ctx =*/ 16384,
/*.offset_ms =*/ 0,
/*.duration_ms =*/ 0,

/*.translate =*/ false,
/*.no_context =*/ false,
Expand Down Expand Up @@ -2376,6 +2377,7 @@ struct whisper_full_params whisper_full_default_params(enum whisper_sampling_str
/*.n_threads =*/ std::min(4, (int32_t) std::thread::hardware_concurrency()),
/*.n_max_text_ctx =*/ 16384,
/*.offset_ms =*/ 0,
/*.duration_ms =*/ 0,

/*.translate =*/ false,
/*.no_context =*/ false,
Expand Down Expand Up @@ -2496,11 +2498,12 @@ int whisper_full(
}

const int seek_start = params.offset_ms/10;
const int seek_end = seek_start + (params.duration_ms == 0 ? whisper_n_len(ctx) : params.duration_ms/10);

// if length of spectrogram is less than 1s (100 samples), then return
// basically don't process anything that is less than 1s
// see issue #39: https://github.com/ggerganov/whisper.cpp/issues/39
if (whisper_n_len(ctx) < 100 + seek_start) {
if (seek_end < 100 + seek_start) {
return 0;
}

Expand Down Expand Up @@ -2533,15 +2536,15 @@ int whisper_full(
// main loop
int seek = seek_start;
while (true) {
int progress_cur = (100*seek)/whisper_n_len(ctx);
const int progress_cur = (100*(seek - seek_start))/(seek_end - seek_start);
while (progress_cur >= progress_prev + progress_step) {
progress_prev += progress_step;
if (params.print_progress) {
fprintf(stderr, "%s: progress = %3d%%\n", __func__, progress_prev);
}
}

if (seek + 100 >= whisper_n_len(ctx)) {
if (seek + 100 >= seek_end) {
break;
}

Expand Down Expand Up @@ -2622,7 +2625,7 @@ int whisper_full(
// end of text token
if (token.id == whisper_token_eot(ctx)) {
if (result_len == 0) {
if (seek + seek_delta + 100 >= whisper_n_len(ctx)) {
if (seek + seek_delta + 100 >= seek_end) {
result_len = i + 1;
} else {
// TODO: figure out how to resolve this
Expand Down

0 comments on commit d5a7c79

Please sign in to comment.