63 main(int32 argc,
char **argv)
67 int32 k, uttno, ts, uttlen, sps, endsilsamples;
74 (sscanf(argv[1],
"%d", &sps) != 1) ||
75 (sscanf(argv[2],
"%f", &endsil) != 1) || (endsil <= 0.0)) {
76 E_FATAL(
"Usage: %s <sampling-rate> <utt-end-sil(sec)>\n", argv[0]);
80 endsilsamples = (int32) (endsil * sps);
84 E_FATAL(
"ad_open_sps(%d) failed\n", sps);
88 E_FATAL(
"cont_ad_init failed\n");
91 printf(
"Calibrating ...");
100 printf(
"You may speak now\n");
107 E_FATAL(
"cont_ad_read failed\n");
111 sprintf(file,
"%04d.raw", uttno);
112 if ((fp = fopen(file,
"wb")) == NULL)
114 fwrite(buf,
sizeof(int16), k, fp);
116 printf(
"Utterance %04d, logging to %s\n", uttno, file);
124 E_FATAL(
"cont_ad_read failed\n");
130 if ((cont->
read_ts - ts) > endsilsamples)
137 fwrite(buf,
sizeof(int16), k, fp);
142 printf(
"\tUtterance %04d = %d samples (%.1fsec)\n\n",
143 uttno, uttlen, (
double) uttlen / (
double) sps);
SPHINXBASE_EXPORT int32 cont_ad_read(cont_ad_t *r, int16 *buf, int32 max)
Read raw audio data into the silence filter.
Continuous A/D listening and silence filtering module.
Basic type definitions used in Sphinx.
#define E_FATAL_SYSTEM
Print error text; Call perror(""); exit(errno);.
SPHINXBASE_EXPORT int32 cont_ad_close(cont_ad_t *cont)
Close the continuous listening object.
SPHINXBASE_EXPORT cont_ad_t * cont_ad_init(ad_rec_t *ad, int32(*adfunc)(ad_rec_t *ad, int16 *buf, int32 max))
Initialize a continuous listening/silence filtering object.
SPHINXBASE_EXPORT int32 cont_ad_calib(cont_ad_t *cont)
Calibrate the silence filter.
Implementation of logging routines.
generic live audio interface for recording and playback
Continuous listening module or object Continuous listening module or object.
#define E_FATAL
Exit with non-zero status after error message.
int32 read_ts
Absolute timestamp (total no.
SPHINXBASE_EXPORT ad_rec_t * ad_open_sps(int32 samples_per_sec)
Open the default audio device with a given sampling rate.