@@ -971,7 +971,6 @@ struct whisper_state {
971
971
bool has_vad_segments = false ;
972
972
973
973
std::vector<vad_time_mapping> vad_mapping_table;
974
- bool vad_mapping_table_initialized = false ;
975
974
};
976
975
977
976
struct whisper_context {
@@ -6638,7 +6637,7 @@ static bool whisper_vad(
6638
6637
6639
6638
// Clear any existing mapping table
6640
6639
state->vad_mapping_table .clear ();
6641
- state->vad_mapping_table_initialized = false ;
6640
+ state->has_vad_segments = false ;
6642
6641
6643
6642
if (state->vad_context == nullptr ) {
6644
6643
struct whisper_vad_context_params vad_ctx_params = whisper_vad_default_context_params ();
@@ -6663,7 +6662,6 @@ static bool whisper_vad(
6663
6662
// Initialize the time mapping table
6664
6663
state->vad_mapping_table .clear ();
6665
6664
state->vad_mapping_table .reserve (vad_segments->data .size () * 4 );
6666
- state->vad_mapping_table_initialized = true ;
6667
6665
6668
6666
WHISPER_LOG_INFO (" %s: detected %d speech segments\n " , __func__, (int )vad_segments->data .size ());
6669
6667
float overlap_seconds = vad_params.samples_overlap ;
@@ -7937,8 +7935,7 @@ static int64_t map_processed_to_original_time(int64_t processed_time, const std:
7937
7935
// Function to get the starting timestamp of a segment
7938
7936
int64_t whisper_full_get_segment_t0_from_state (struct whisper_state * state, int i_segment) {
7939
7937
// If VAD wasn't used, return the original timestamp
7940
- if (!state->has_vad_segments || !state->vad_mapping_table_initialized ||
7941
- state->vad_mapping_table .empty ()) {
7938
+ if (!state->has_vad_segments || state->vad_mapping_table .empty ()) {
7942
7939
return state->result_all [i_segment].t0 ;
7943
7940
}
7944
7941
@@ -7952,8 +7949,7 @@ int64_t whisper_full_get_segment_t0_from_state(struct whisper_state* state, int
7952
7949
// Function to get the ending timestamp of a segment
7953
7950
int64_t whisper_full_get_segment_t1_from_state (struct whisper_state * state, int i_segment) {
7954
7951
// If VAD wasn't used, return the original timestamp
7955
- if (!state->has_vad_segments || !state->vad_mapping_table_initialized ||
7956
- state->vad_mapping_table .empty ()) {
7952
+ if (!state->has_vad_segments || state->vad_mapping_table .empty ()) {
7957
7953
return state->result_all [i_segment].t1 ;
7958
7954
}
7959
7955
0 commit comments