ggerganov commited on
Commit
51d2d34
·
unverified ·
1 Parent(s): 5692844

whisper : more debug messages + fix fallback logic

Browse files
Files changed (1) hide show
  1. whisper.cpp +15 -11
whisper.cpp CHANGED
@@ -5028,6 +5028,7 @@ int whisper_full_with_state(
5028
  // basically don't process anything that is less than 1.0s
5029
  // see issue #39: https://github.com/ggerganov/whisper.cpp/issues/39
5030
  if (seek_end < seek_start + (params.speed_up ? 50 : 100)) {
 
5031
  return 0;
5032
  }
5033
 
@@ -5455,6 +5456,7 @@ int whisper_full_with_state(
5455
 
5456
  // do not allow to go back in time
5457
  if (has_ts && seek_delta > seek_delta_new && result_len < i) {
 
5458
  failed = true; // TODO: maybe this is not a failure ?
5459
  continue;
5460
  }
@@ -5483,6 +5485,7 @@ int whisper_full_with_state(
5483
  if (seek + seek_delta + 100 >= seek_end) {
5484
  result_len = i + 1;
5485
  } else {
 
5486
  failed = true;
5487
  continue;
5488
  }
@@ -5493,6 +5496,7 @@ int whisper_full_with_state(
5493
  seek_delta = 100*WHISPER_CHUNK_SIZE;
5494
  }
5495
 
 
5496
  completed = true;
5497
  continue;
5498
  }
@@ -5508,6 +5512,7 @@ int whisper_full_with_state(
5508
  // sometimes, the decoding can get stuck in a repetition loop
5509
  // this is an attempt to mitigate such cases - we flag the decoding as failed and use a fallback strategy
5510
  if (i == n_max - 1 && (result_len == 0 || seek_delta < 100*WHISPER_CHUNK_SIZE/2)) {
 
5511
  failed = true;
5512
  continue;
5513
  }
@@ -5651,28 +5656,27 @@ int whisper_full_with_state(
5651
  WHISPER_PRINT_DEBUG("%s: best decoder = %d\n", __func__, best_decoder_id);
5652
  }
5653
 
 
 
5654
  // was the decoding successful for the current temperature?
5655
  // do fallback only if:
5656
  // - we are not at the last temperature
5657
- // - we are not at the end of the audio (3 sec)
5658
- if (it != (int) temperatures.size() - 1 &&
5659
- seek_end - seek > 10*WHISPER_CHUNK_SIZE) {
5660
- bool success = true;
5661
-
5662
  const auto & decoder = state->decoders[best_decoder_id];
5663
 
5664
  if (decoder.failed || decoder.sequence.avg_logprobs < params.logprob_thold) {
 
5665
  success = false;
5666
  state->n_fail_p++;
5667
  }
 
5668
 
5669
- if (success) {
5670
- //for (auto & token : ctx->decoders[best_decoder_id].sequence.tokens) {
5671
- // WHISPER_PRINT_DEBUG("%s: token = %d, p = %6.3f, pt = %6.3f, ts = %s, str = %s\n", __func__, token.id, token.p, token.pt, ctx->vocab.id_to_token.at(token.tid).c_str(), ctx->vocab.id_to_token.at(token.id).c_str());
5672
- //}
5673
 
5674
- break;
5675
- }
5676
  }
5677
 
5678
  WHISPER_PRINT_DEBUG("\n%s: failed to decode with temperature = %.2f\n", __func__, t_cur);
 
5028
  // basically don't process anything that is less than 1.0s
5029
  // see issue #39: https://github.com/ggerganov/whisper.cpp/issues/39
5030
  if (seek_end < seek_start + (params.speed_up ? 50 : 100)) {
5031
+ WHISPER_PRINT_DEBUG("%s: input is too short - %d ms < 1000 ms\n", __func__, (seek_end - seek_start)*10);
5032
  return 0;
5033
  }
5034
 
 
5456
 
5457
  // do not allow to go back in time
5458
  if (has_ts && seek_delta > seek_delta_new && result_len < i) {
5459
+ WHISPER_PRINT_DEBUG("%s: decoder %d: failed due to seek_delta (%d > %d)\n", __func__, j, seek_delta, seek_delta_new);
5460
  failed = true; // TODO: maybe this is not a failure ?
5461
  continue;
5462
  }
 
5485
  if (seek + seek_delta + 100 >= seek_end) {
5486
  result_len = i + 1;
5487
  } else {
5488
+ WHISPER_PRINT_DEBUG("%s: decoder %d failed (result_len = 0)\n", __func__, j);
5489
  failed = true;
5490
  continue;
5491
  }
 
5496
  seek_delta = 100*WHISPER_CHUNK_SIZE;
5497
  }
5498
 
5499
+ WHISPER_PRINT_DEBUG("%s: decoder %d completed\n", __func__, j);
5500
  completed = true;
5501
  continue;
5502
  }
 
5512
  // sometimes, the decoding can get stuck in a repetition loop
5513
  // this is an attempt to mitigate such cases - we flag the decoding as failed and use a fallback strategy
5514
  if (i == n_max - 1 && (result_len == 0 || seek_delta < 100*WHISPER_CHUNK_SIZE/2)) {
5515
+ WHISPER_PRINT_DEBUG("%s: decoder %d: failed due to repetition loop\n", __func__, j);
5516
  failed = true;
5517
  continue;
5518
  }
 
5656
  WHISPER_PRINT_DEBUG("%s: best decoder = %d\n", __func__, best_decoder_id);
5657
  }
5658
 
5659
+ bool success = true;
5660
+
5661
  // was the decoding successful for the current temperature?
5662
  // do fallback only if:
5663
  // - we are not at the last temperature
5664
+ if (it != (int) temperatures.size() - 1) {
 
 
 
 
5665
  const auto & decoder = state->decoders[best_decoder_id];
5666
 
5667
  if (decoder.failed || decoder.sequence.avg_logprobs < params.logprob_thold) {
5668
+ WHISPER_PRINT_DEBUG("%s: failed due to avg_logprobs %8.5f < %8.5f\n", __func__, decoder.sequence.avg_logprobs, params.logprob_thold);
5669
  success = false;
5670
  state->n_fail_p++;
5671
  }
5672
+ }
5673
 
5674
+ if (success) {
5675
+ //for (auto & token : ctx->decoders[best_decoder_id].sequence.tokens) {
5676
+ // WHISPER_PRINT_DEBUG("%s: token = %d, p = %6.3f, pt = %6.3f, ts = %s, str = %s\n", __func__, token.id, token.p, token.pt, ctx->vocab.id_to_token.at(token.tid).c_str(), ctx->vocab.id_to_token.at(token.id).c_str());
5677
+ //}
5678
 
5679
+ break;
 
5680
  }
5681
 
5682
  WHISPER_PRINT_DEBUG("\n%s: failed to decode with temperature = %.2f\n", __func__, t_cur);