@@ -145,17 +145,11 @@ int main(int argc, char ** argv) {
145145 ctx_params.flash_attn = params.flash_attn ;
146146 ctx_params.gpu_device = params.gpu_device ;
147147
148- struct parakeet_context * pctx = parakeet_init_from_file_with_params_no_state (params.model .c_str (), ctx_params);
148+ struct parakeet_context * pctx = parakeet_init_from_file_with_params (params.model .c_str (), ctx_params);
149149 if (pctx == nullptr ) {
150150 fprintf (stderr, " error: failed to load Parakeet model from '%s'\n " , params.model .c_str ());
151151 return 1 ;
152152 }
153- struct parakeet_state * state = parakeet_init_state (pctx);
154- if (state == nullptr ) {
155- fprintf (stderr, " error: failed to initialize parakeet state\n " );
156- parakeet_free (pctx);
157- return 2 ;
158- }
159153
160154 fprintf (stderr, " Successfully loaded Parakeet model\n " );
161155 fprintf (stderr, " Processing audio (%zu samples, %.2f seconds)\n " ,
@@ -169,41 +163,36 @@ int main(int argc, char ** argv) {
169163 full_params.new_token_callback = token_callback;
170164 full_params.new_token_callback_user_data = nullptr ;
171165
172- const int mel_frames = pcmf32.size () / PARAKEET_HOP_LENGTH;
173- const int model_max_ctx = parakeet_n_audio_ctx (pctx);
174- const bool fits_single_chunk = mel_frames <= model_max_ctx;
175-
176- int ret;
177- if (fits_single_chunk) {
178- ret = parakeet_chunk (pctx, state, full_params, pcmf32.data (), pcmf32.size ());
179- } else {
180- ret = parakeet_full_with_state (pctx, state, full_params, pcmf32.data (), pcmf32.size ());
166+ const int mel_frames = (int )(pcmf32.size () / PARAKEET_HOP_LENGTH);
167+ if (mel_frames <= parakeet_n_audio_ctx (pctx)) {
168+ full_params.chunk_length_ms = 0 ;
181169 }
182170
171+ int ret = parakeet_full (pctx, full_params, pcmf32.data (), pcmf32.size ());
172+
183173 if (ret != 0 ) {
184174 fprintf (stderr, " error: failed to process audio file '%s'\n " , fname.c_str ());
185- parakeet_free_state (state);
186175 parakeet_free (pctx);
187176 continue ;
188177 }
189178
190179 printf (" \n " );
191180
192181 if (params.print_segments ) {
193- const int n_segments = parakeet_full_n_segments_from_state (state );
182+ const int n_segments = parakeet_full_n_segments (pctx );
194183 fprintf (stderr, " \n Segments (%d):\n " , n_segments);
195184
196185 for (int i = 0 ; i < n_segments; i++) {
197- const char * text = parakeet_full_get_segment_text_from_state (state , i);
198- const int64_t t0 = parakeet_full_get_segment_t0_from_state (state , i);
199- const int64_t t1 = parakeet_full_get_segment_t1_from_state (state , i);
200- const int n_tokens = parakeet_full_n_tokens_from_state (state , i);
186+ const char * text = parakeet_full_get_segment_text (pctx , i);
187+ const int64_t t0 = parakeet_full_get_segment_t0 (pctx , i);
188+ const int64_t t1 = parakeet_full_get_segment_t1 (pctx , i);
189+ const int n_tokens = parakeet_full_n_tokens (pctx , i);
201190
202191 fprintf (stderr, " Segment %d: [%lld -> %lld] \" %s\"\n " , i, (long long )t0, (long long )t1, text);
203192 fprintf (stderr, " Tokens [%d]:\n " , n_tokens);
204193
205194 for (int j = 0 ; j < n_tokens; j++) {
206- parakeet_token_data token_data = parakeet_full_get_token_data_from_state (state , i, j);
195+ parakeet_token_data token_data = parakeet_full_get_token_data (pctx , i, j);
207196 const char * token_str = parakeet_token_to_str (pctx, token_data.id );
208197
209198 fprintf (stderr, " [%2d] id=%5d frame=%3d dur_idx=%2d dur_val=%2d p=%.4f plog=%.4f t0=%4lld t1=%4lld word_start=%s \" %s\"\n " ,
@@ -222,7 +211,6 @@ int main(int argc, char ** argv) {
222211 }
223212 }
224213
225- parakeet_free_state (state);
226214 parakeet_free (pctx);
227215 }
228216
0 commit comments