Julius 4.2
libsent/src/anlz/strip.c
説明を見る。
00001 
00017 /*
00018  * Copyright (c) 1991-2011 Kawahara Lab., Kyoto University
00019  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00020  * Copyright (c) 2005-2011 Julius project team, Nagoya Institute of Technology
00021  * All rights reserved
00022  */
00023 
00024 #include <sent/stddefs.h>
00025 #include <sent/speech.h>
00026 
00028 #define IS_INVALID_SAMPLE(A) ((A) == 0 || (A) == -32767)
00029 
00030 #define WINDOWLEN 16
00031 
00040 int
00041 strip_zero(SP16 a[], int len)
00042 {
00043   int src,dst;
00044   int bgn,mode,j;
00045 
00046   dst = 0;
00047   bgn = 0;
00048   mode = 0;
00049 
00050   for (src = 0; src < len; src++) {
00051     if (IS_INVALID_SAMPLE(a[src])) {
00052       if (mode == 0) {          /* first time */
00053         bgn = src;
00054         mode = 1;
00055       }
00056       /* skip */
00057     } else {
00058       if (mode == 1) {
00059         mode = 0;
00060         if ((src - bgn) < WINDOWLEN) {
00061           for(j=bgn;j<src;j++) {
00062             a[dst++] = a[j];
00063           }
00064         } else {
00065           /* deleted (leave uncopied) */
00066           jlog("Warning: strip: sample %d-%d has zero value, stripped\n", bgn, src-1);
00067         }
00068       }
00069       a[dst++] = a[src];
00070     }
00071   }
00072   /* end process */
00073   if (mode == 1) {
00074     mode = 0;
00075     if ((src - bgn) < WINDOWLEN) {
00076       /* restore */
00077       for(j=bgn;j<src;j++) {
00078         a[dst++] = a[j];
00079       }
00080     } else {
00081       /* deleted (leave uncopied) */
00082       jlog("Warning: strip: sample %d-%d is invalid, stripped\n", bgn, src-1);
00083     }
00084   }
00085   
00086   return(dst);
00087 }