# Multimode Tree-Coding of Speech with Pre-/Post-Weighting +
## 8 Voice Activity Detection (VAD) and Mode Decision  
Most high-performance codecs today use some approach to VAD. Usually these methods are quite complex, such as in [8]. Our approach is much simpler since the codec is backward adaptive and low delay and relies more on the available codec parameters. The VAD method developed here is an entirely new, simplified approach. Figure 5: Pre-weighting and post-weighting filters for speech codec. The flow chart of our mode decision is shown in Figure 6. The mode decision is a low-delay, low-complexity method based on the ADPCM coder state parameters, unlocked scale factor \(y_{u}\) and long-term average magnitude of weighted quantization level \(d_{ml}\), along with the absolute magnitude of each frame and zero crossing rate. The input to the mode decision is a speech frame consisting of 40 samples of 8 kHz narrowband speech, and the output is the classification of the frame among one of these five modes: Voiced (V); Onset (ON); Unvoiced (UV); Hangover (H); and Silence (S). In the following, the term \"Voice\" is used to denote all non-silence speech and the term \"Voiced\" is used to denote the Voiced (V) mode of speech. The input frame of speech is first classified into Voice/Silence by Voice Activity Detection (VAD) before further classification into five modes. The unlocked scale factor \(y_{u}\) is updated for the adaptive quantizer in the G.727 ADPCM coder. The long-term average magnitude of weighted quantization level \(d_{ml}\) is calculated. The absolute magnitude of each frame \(f_{e}\) is widely used in VAD algorithms. It is computed for each frame \(i\) as follows,  
\[f_{e}(i)=\sum_{k=i}^{i+N-1}|s(k)|, \tag{20}\]  
where \(s\) is the normalized input speech signal, normalized to input speech power, and \(N\) is the length of a speech frame. The number of zero-crossings ZC is widely used for voiced and unvoiced classification, which is defined as:  
\[ZC(i)=\frac{1}{2}\sum_{k=i+1}^{i+N-1}|\text{sgn}[s(k)]-\text{sgn}[s(k-1)]|, \tag{21}\]  
with \(\text{sgn}(\cdot)\) the sign function returning \(\pm 1\) depending on the sign of the operand. The unlocked scale factor \(y_{u}\), long-term average magnitude of weighted quantization level \(d_{ml}\), and frame energy \(f_{e}\) are high during Voice sequences and low during Silence sequence. Therefore, the three parameters are compared against threshold values computed for each parameter to make a Voice Activity Detection decision. If \(y_{u}\) or \(d_{ml}\) is greater than its threshold, \(y_{VAD}\) or \(d_{VAD}\), and \(f_{e}\) is greater than the threshold \(f_{VAD}\), then the frame is marked as Voice. If \(y_{u}\) and \(d_{ml}\) are smaller than their thresholds, \(y_{VAD}\) and \(d_{VAD}\), and the status continues for at least 15 frames, then the frame is marked as Silence. After Voice Activity Detection, each frame should be further classified into Voiced (V), Onset (ON), Unvoiced (UV), or Hangover (H). For the frame marked as Voice, it will  
Figure 6: Flow chart of the mode decision. be further classified into Unvoiced (UV), Onset (ON) or Voiced (V). If \(y_{u}\), \(d_{ml}\), and \(f_{e}\) are smaller than their thresholds, \(y_{VOICE}\), \(d_{VOICE}\), and \(f_{VOICE}\), and \(ZC\) is greater than the threshold \(ZC_{VOICE}\), the frame is classified as Unvoiced (UV). Otherwise, it is classified as Voiced (V). The first Voiced frame following Unvoiced or Silence frame is marked as Onset (ON). For the frame marked as Silence, it will be further classified into Silence (S), or Hangover (H). The first ten Silence frames following Voiced are marked as Hangover (H). Otherwise, it is marked as Silence (S). Table 1 shows the details of the test sequences. The test sequences are all longer than one sentence, and there are four female and four male speakers. The sentences were chosen to cover a wide range of difficult-to-code phonemes and words. The sentence, \"We were away a year ago,\" is included since it is almost totally voiced, without unvoiced sounds or silence.