Spaces:
Sleeping
Sleeping
whisper : condition timestamps to be monotonically increasing (#425)
Browse files- whisper.cpp +10 -0
whisper.cpp
CHANGED
|
@@ -2988,6 +2988,16 @@ static void whisper_process_logits(
|
|
| 2988 |
}
|
| 2989 |
}
|
| 2990 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2991 |
// populate the logprobs array (log_softmax)
|
| 2992 |
{
|
| 2993 |
const float logit_max = *std::max_element(logits.begin(), logits.end());
|
|
|
|
| 2988 |
}
|
| 2989 |
}
|
| 2990 |
|
| 2991 |
+
// condition timestamp tokens to be increasing
|
| 2992 |
+
// ref: https://github.com/openai/whisper/pull/831#issuecomment-1385910556
|
| 2993 |
+
if (decoder.has_ts) {
|
| 2994 |
+
const int tid0 = decoder.seek_delta/2;
|
| 2995 |
+
|
| 2996 |
+
for (int i = vocab.token_beg; i < vocab.token_beg + tid0; ++i) {
|
| 2997 |
+
logits[i] = -INFINITY;
|
| 2998 |
+
}
|
| 2999 |
+
}
|
| 3000 |
+
|
| 3001 |
// populate the logprobs array (log_softmax)
|
| 3002 |
{
|
| 3003 |
const float logit_max = *std::max_element(logits.begin(), logits.end());
|