boolemancer ggerganov commited on
Commit
9c311e8
·
unverified ·
1 Parent(s): 8060473

whisper : fix sample_to_timestamp calculation with 64 bit precision to avoid overflow (#388)

Browse files

* Do calculation with 64 bit precision to avoid overflow

* Update whisper.cpp

Co-authored-by: Georgi Gerganov <[email protected]>

Co-authored-by: Georgi Gerganov <[email protected]>

Files changed (1) hide show
  1. whisper.cpp +1 -1
whisper.cpp CHANGED
@@ -3388,7 +3388,7 @@ static int timestamp_to_sample(int64_t t, int n_samples) {
3388
  }
3389
 
3390
  static int64_t sample_to_timestamp(int i_sample) {
3391
- return (100*i_sample)/WHISPER_SAMPLE_RATE;
3392
  }
3393
 
3394
  // a cost-function / heuristic that is high for text that takes longer to pronounce
 
3388
  }
3389
 
3390
  static int64_t sample_to_timestamp(int i_sample) {
3391
+ return (100ll*i_sample)/WHISPER_SAMPLE_RATE;
3392
  }
3393
 
3394
  // a cost-function / heuristic that is high for text that takes longer to pronounce