1 /* -*- c-basic-offset: 4 -*- */
8 #include "test_macros.h"
12 #ifndef WORDS_BIGENDIAN
13 #define WORDS_BIGENDIAN 0
17 main(int argc, char *argv[])
26 TEST_ASSERT(infp = fopen(TESTDATADIR "/chan3.raw", "rb"));
27 TEST_ASSERT(cont = cont_ad_init(NULL, NULL));
29 n_calib_samp = cont_ad_calib_size(cont);
30 calib = ckd_malloc(n_calib_samp * 2);
31 printf("Reading %d calibration samples\n", n_calib_samp);
32 TEST_ASSERT(fread(calib, 2, n_calib_samp, infp) == n_calib_samp);
33 printf("Calibrating...\n");
34 TEST_EQUAL(0, cont_ad_calib_loop(cont, calib, n_calib_samp));
35 printf("Calibrated!\n");
40 /* Use up the calibration samples first. */
45 memcpy(buf, cptr, 512 * 2);
49 k = fread(buf + k, 2, 512-k, infp);
52 k = fread(buf, 2, 512, infp);
56 if (k < 256) { /* FIXME: It should do something useful with fewer samples. */
58 printf("End of file at %.3f seconds\n",
59 (double)(cont->read_ts - k) / 16000);
64 k = cont_ad_read(cont, buf, k);
66 if (cont->state == CONT_AD_STATE_SIL) {
67 /* Has there been enough silence to cut the utterance? */
68 if (listening && cont->seglen > 8000) {
69 printf("End of utterance at %.3f seconds\n",
70 (double)(cont->read_ts - k - cont->seglen) / 16000);
76 printf("Start of utterance at %.3f seconds\n",
77 (double)(cont->read_ts - k) / 16000);