@@ -2472,12 +2472,12 @@ int whisper_lang_auto_detect(
24722472 }
24732473
24742474 {
2475- for (int i = 0 ; i < ( int ) probs_id. size (); i++ ) {
2475+ for (const auto & prob : probs_id) {
24762476 if (lang_probs) {
2477- lang_probs[probs_id[i] .second ] = probs_id[i] .first ;
2477+ lang_probs[prob .second ] = prob .first ;
24782478 }
24792479
2480- // printf("%s: lang %2d (%3s): %f\n", __func__, probs_id[i] .second, whisper_lang_str(probs_id[i] .second), probs_id[i] .first);
2480+ // printf("%s: lang %2d (%3s): %f\n", __func__, prob .second, whisper_lang_str(prob .second), prob .first);
24812481 }
24822482 }
24832483
@@ -3225,17 +3225,17 @@ int whisper_full_parallel(
32253225 for (int i = 0 ; i < n_processors - 1 ; ++i) {
32263226 auto & results_i = ctxs[i].result_all ;
32273227
3228- for (int j = 0 ; j < ( int ) results_i. size (); ++j ) {
3228+ for (auto & result : results_i) {
32293229 // correct the segment timestamp taking into account the offset
3230- results_i[j] .t0 += 100 *((i + 1 )*n_samples_per_processor)/WHISPER_SAMPLE_RATE + offset_t ;
3231- results_i[j] .t1 += 100 *((i + 1 )*n_samples_per_processor)/WHISPER_SAMPLE_RATE + offset_t ;
3230+ result .t0 += 100 *((i + 1 )*n_samples_per_processor)/WHISPER_SAMPLE_RATE + offset_t ;
3231+ result .t1 += 100 *((i + 1 )*n_samples_per_processor)/WHISPER_SAMPLE_RATE + offset_t ;
32323232
32333233 // make sure that segments are not overlapping
32343234 if (!ctx->result_all .empty ()) {
3235- results_i[j] .t0 = std::max (results_i[j] .t0 , ctx->result_all .back ().t1 );
3235+ result .t0 = std::max (result .t0 , ctx->result_all .back ().t1 );
32363236 }
32373237
3238- ctx->result_all .push_back (std::move (results_i[j] ));
3238+ ctx->result_all .push_back (std::move (result ));
32393239
32403240 // call the new_segment_callback for each segment
32413241 if (params.new_segment_callback ) {
@@ -3330,18 +3330,18 @@ static int64_t sample_to_timestamp(int i_sample) {
33303330static float voice_length (const std::string & text) {
33313331 float res = 0 .0f ;
33323332
3333- for (size_t i = 0 ; i < text. size (); ++i ) {
3334- if (text[i] == ' ' ) {
3333+ for (char c : text) {
3334+ if (c == ' ' ) {
33353335 res += 0 .01f ;
3336- } else if (text[i] == ' ,' ) {
3336+ } else if (c == ' ,' ) {
33373337 res += 2 .00f ;
3338- } else if (text[i] == ' .' ) {
3338+ } else if (c == ' .' ) {
33393339 res += 3 .00f ;
3340- } else if (text[i] == ' !' ) {
3340+ } else if (c == ' !' ) {
33413341 res += 3 .00f ;
3342- } else if (text[i] == ' ?' ) {
3342+ } else if (c == ' ?' ) {
33433343 res += 3 .00f ;
3344- } else if (text[i] >= ' 0' && text[i] <= ' 9' ) {
3344+ } else if (c >= ' 0' && c <= ' 9' ) {
33453345 res += 3 .00f ;
33463346 } else {
33473347 res += 1 .00f ;
0 commit comments