@@ -2472,12 +2472,12 @@ int whisper_lang_auto_detect(
2472
2472
}
2473
2473
2474
2474
{
2475
- for (int i = 0 ; i < ( int ) probs_id. size (); i++ ) {
2475
+ for (const auto & prob : probs_id) {
2476
2476
if (lang_probs) {
2477
- lang_probs[probs_id[i] .second ] = probs_id[i] .first ;
2477
+ lang_probs[prob .second ] = prob .first ;
2478
2478
}
2479
2479
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);
2481
2481
}
2482
2482
}
2483
2483
@@ -3225,17 +3225,17 @@ int whisper_full_parallel(
3225
3225
for (int i = 0 ; i < n_processors - 1 ; ++i) {
3226
3226
auto & results_i = ctxs[i].result_all ;
3227
3227
3228
- for (int j = 0 ; j < ( int ) results_i. size (); ++j ) {
3228
+ for (auto & result : results_i) {
3229
3229
// 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 ;
3232
3232
3233
3233
// make sure that segments are not overlapping
3234
3234
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 );
3236
3236
}
3237
3237
3238
- ctx->result_all .push_back (std::move (results_i[j] ));
3238
+ ctx->result_all .push_back (std::move (result ));
3239
3239
3240
3240
// call the new_segment_callback for each segment
3241
3241
if (params.new_segment_callback ) {
@@ -3330,18 +3330,18 @@ static int64_t sample_to_timestamp(int i_sample) {
3330
3330
static float voice_length (const std::string & text) {
3331
3331
float res = 0 .0f ;
3332
3332
3333
- for (size_t i = 0 ; i < text. size (); ++i ) {
3334
- if (text[i] == ' ' ) {
3333
+ for (char c : text) {
3334
+ if (c == ' ' ) {
3335
3335
res += 0 .01f ;
3336
- } else if (text[i] == ' ,' ) {
3336
+ } else if (c == ' ,' ) {
3337
3337
res += 2 .00f ;
3338
- } else if (text[i] == ' .' ) {
3338
+ } else if (c == ' .' ) {
3339
3339
res += 3 .00f ;
3340
- } else if (text[i] == ' !' ) {
3340
+ } else if (c == ' !' ) {
3341
3341
res += 3 .00f ;
3342
- } else if (text[i] == ' ?' ) {
3342
+ } else if (c == ' ?' ) {
3343
3343
res += 3 .00f ;
3344
- } else if (text[i] >= ' 0' && text[i] <= ' 9' ) {
3344
+ } else if (c >= ' 0' && c <= ' 9' ) {
3345
3345
res += 3 .00f ;
3346
3346
} else {
3347
3347
res += 1 .00f ;
0 commit comments