julius/m_adin.c

Go to the documentation of this file.
00001 
00017 /*
00018  * Copyright (c) 1991-2006 Kawahara Lab., Kyoto University
00019  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00020  * Copyright (c) 2005-2006 Julius project team, Nagoya Institute of Technology
00021  * All rights reserved
00022  */
00023 
00024 #include <julius.h>
00025 
00038 void
00039 adin_initialize()
00040 {
00041   char *arg = NULL;
00042   boolean igsp = TRUE;
00043 
00044   if (speech_input == SP_MFCFILE) return; /* no need to initialize */
00045   
00046   VERMES("###### initialize input device\n");
00047 
00048   /* select input device: file, mic, netaudio, etc... */
00049   if (adin_select(speech_input) == FALSE) {
00050     j_error("Error: invalid input device\n");
00051   }
00052 
00053   /* set sampling frequency and device-dependent configuration
00054      (argument is device-dependent) */
00055   switch(speech_input) {
00056   case SP_ADINNET:              /* arg: port number */
00057     arg = mymalloc(100);
00058     sprintf(arg, "%d", adinnet_port);
00059     break;
00060   case SP_RAWFILE:              /* arg: filename of file list (if any) */
00061     if (inputlist_filename != NULL) {
00062       arg = mymalloc(strlen(inputlist_filename)+1);
00063       strcpy(arg, inputlist_filename);
00064     } else {
00065       arg = NULL;
00066     }
00067     break;
00068   case SP_STDIN:
00069     arg = NULL;
00070     break;
00071 #ifdef USE_NETAUDIO
00072   case SP_NETAUDIO:             /* netaudio server/port name */
00073     arg = mymalloc(strlen(netaudio_devname)+1);
00074     strcpy(arg, netaudio_devname);
00075     break;
00076 #endif
00077   }
00078 
00079   if (speech_input == SP_MIC) {
00080 #ifdef SP_BREAK_CURRENT_FRAME
00081     igsp = FALSE;               /* does not drop speech while decoding */
00082 #endif
00083   }
00084   
00085   if (adin_standby(para.smp_freq, arg) == FALSE) { /* fail */
00086     j_error("Error: failed to ready input device\n");
00087   }
00088 
00089   /* set parameter for recording/silence detection */
00090   adin_setup_param(silence_cut,/* silence cutting: 0=off,1=on,2=use device default */
00091                    strip_zero_sample, /* strip zero sample if TRUE */
00092                    level_thres, /* trigger level threshold (0-32767) */
00093                    zero_cross_num, /* zero-cross num for silence detection */
00094                    head_margin_msec, /* margin at beginning of input segment */
00095                    tail_margin_msec, /* margin at end of input segment */
00096                    para.smp_freq, /* sampling frequency */
00097                    igsp,        /* TRUE if ignore speech while decoding */
00098                    use_zmean);  /* TRUE if need zmeansource */
00099 
00100   if (arg != NULL) free(arg);
00101 }

Generated on Tue Dec 26 12:53:21 2006 for Julian by  doxygen 1.5.0