Home | History | Annotate | Download | only in include
      1 /*---------------------------------------------------------------------------*
      2  *  voicing.h  *
      3  *                                                                           *
      4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
      5  *                                                                           *
      6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
      7  *  you may not use this file except in compliance with the License.         *
      8  *                                                                           *
      9  *  You may obtain a copy of the License at                                  *
     10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
     11  *                                                                           *
     12  *  Unless required by applicable law or agreed to in writing, software      *
     13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
     14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
     15  *  See the License for the specific language governing permissions and      *
     16  *  limitations under the License.                                           *
     17  *                                                                           *
     18  *---------------------------------------------------------------------------*/
     19 
     20 
     21 
     22 #ifndef __voicing_h
     23 #define __voicing_h
     24 
     25 #ifdef SET_RCSID
     26 static const char voicing_h[] = "$Id: voicing.h,v 1.1.10.3 2007/08/31 17:44:53 dahan Exp $";
     27 #endif
     28 
     29 
     30 #include "hmm_type.h"
     31 
     32 #define B0_HANG1 100
     33 #define B0_HANG2 300
     34 #define B0_RATE1 15     /* 256 * 0.06 */
     35 #define B0_RATE2 38     /* 256 * 0.15 */
     36 #define B1_RATE  26     /* 256 * 0.1 */
     37 #define DYNAMIC_RANGE (70 << 8)   /* typical dynamic range */
     38 
     39 /*  The following are internal constants used by the voicing detector program
     40 */
     41 #define VOICE_MASK           0xfffffff0
     42 #define VOICE_BIT            0x01L
     43 #define QUIET_BIT            0x02L
     44 #define FAST_VOICE_BIT       0x04L
     45 #define BELOW_THRESHOLD_BIT  0x08L
     46 #define REC_VOICE_BIT      0x10L
     47 #define REC_QUIET_BIT      0x20L
     48 #define REC_UNSURE_BIT       0x40L
     49 
     50 #define VOICING_DATA(X)      ((X) & (VOICE_BIT | QUIET_BIT))
     51 #define FAST_MATCH_DATA(X)   ((X) & (FAST_VOICE_BIT | QUIET_BIT))
     52 
     53 #define FAST_BIT_SET(X)      ((X) & FAST_VOICE_BIT)
     54 #define QUIET_BIT_SET(X)     ((X) & QUIET_BIT)
     55 #define RECOGNIZER_QUIET(X)  ((X) & REC_QUIET_BIT)
     56 #define SET_VOICING_CODES(X,C) (((X) & ~(REC_VOICE_BIT | REC_QUIET_BIT | REC_UNSURE_BIT)) | (C))
     57 
     58 typedef featdata voicedata;
     59 
     60 typedef struct
     61 {
     62   int   b0;   /* background estimate, level 0 */
     63   int   b1;   /* background estimate, level 1 */
     64   int   s0;
     65   int   margin;
     66   int   fast_margin;
     67   int   quiet_margin;
     68   int   voice_duration; /* threshold for consecutive speech frames */
     69   int   quiet_duration; /* threshold for consecutive silence frames */
     70   int   count;
     71   long  sil_count;  /* no. of consecutive silence frames */
     72   long  fast_count;  /* no. of consecutive speech frames */
     73   long  speech_count;  /* no. of consecutive speech frames for barge-in */
     74   int   voice_status;  /* voicing decision */
     75 }
     76 voicing_info;
     77 
     78 
     79 void init_voicing_analysis(voicing_info *voice);
     80 long voicing_analysis(voicing_info *voice, voicedata enval, int* log);
     81 
     82 #endif
     83