{'fraction_non_alphanumeric': 0.03602594339622642, 'fraction_numerical': 0.009610849056603773, 'mean_word_length': 4.579276315789474, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
CNN self-attention voice activity detector

In this work we present a novel single-channel Voice Activity Detector (VAD) approach. We utilize a Convolutional Neural Network (CNN) which exploits the spatial information of the noisy input spectrum to extract frame-wise embedding sequence, followed by a Self Attention (SA) Encoder with a goal of finding contextual information from the embedding sequence. Different from previous works which were employed on each frame (with context frames) separately, our method is capable of processing the entire signal at once, and thus enabling long receptive field. We show that the fusion of CNN and SA architectures outperforms methods based solely on CNN and SA. Extensive experimental-study shows that our model outperforms previous models on real-life benchmarks, and provides State Of The Art (SOTA) results with relatively small and lightweight model.


I. INTRODUCTION
Accurately detecting the presence or absence of speech in a noisy single-channel recording is still an open issue. The VAD is commonly used as a trigger for different audio processing algorithms, such as speech communication systems, Automatic Speech Recognition (ASR) and echo cancellation. In a noisy and/or reverberant enclosure, the challenge is even more difficult.
Classical signal-processing-based approaches use acoustic features such as zero-crossing rate, pitch detection, and energy thresholds to determine the presence of speech [1]- [3]. Yet, relying on a pre-defined threshold, in real-life scenarios these methods performs poorly. A statistical model was afterwards used to model the speech and noise signals in [4], [5]. Their parameters were learned utilizing the Likelihood Ratio Test (LRT) to determine the most likely hypothesis. Although, a noticeable improvement was gained, these methods are heavily susceptible to non-stationary noise and reverberation conditions.
In recent years, Deep Neural Network (DNN)-based detectors were introduced utilizing dense-networks, CNNs and Recurrent Neural Networks (RNNs) [6]- [11]. These methods have shown promising results compared to the classical algorithms. CNNs are very powerful and widely used models, since they extract useful features from images (including spectrums), which were found beneficial in many downstream tasks including speech-processing algorithms [12], [13]. Typically, a CNN-based VAD system requires employing a flattening operation on the output of the stacked CNN layers, followed by several Fully Connected (FC) layers. This approach has several drawbacks. First, each additional FC layers adds a significant number of trainable parameters. Second, this approach requires a fixed size inputs which tends to be relatively small, resulting in applying the VAD continuously and separately on small parts of the inputs. In addition, the input length constraint prevents long receptive information which might be beneficial for this task. A Fully Convelotional Neural Network (FCNN) architecture can be used to overcome these hurdles, however, the receptive field of this network depends on the depth of the CNN, which is still limited.
One of the first attempts for an attention-based VAD, the Adaptive Context Attention Model (ACAM), was introduced in [14]. Their suggested approach consist of a Long Short-Term Memory (LSTM) and an attention mechanism which allowed the model to focus on relevant input segments. However, Its sequential nature prevent different input segments from relating to each other, which may lead to information loss and catastrophic forgetting. Inspired by the prominence of Self-Attention architecture [15] that is sweeping through most AI-related domains [16]- [18], a SA-based encoder VAD was presented in [19]. The architecture of this model is constructed mainly on SA blocks. The idea behind this architecture is to model the contextual information between the acoustic inputframes. Unfortunately, the SA mechanism is used only on short context frames. Furthermore, without using a CNN on the input, the spectral information of the speech might not be fully exploited.
In this paper, we present a VAD which consist of the fusion of a CNN embedder followed by a self-attention encoder. The CNN is built to preserve the frame information and extract frame-wise features, while the SA-encoder process the entire embedded sequence in order to determine which of all input frames are relevant for classifying each of the frames. We show that the combined architectures performs better than each of its components separately. Furthermore, we show that the proposed methods not only achieve SOTA results on various benchmarks, but also computationally efficient as it is process the entire signal in a single step.

II. PROBLEM FORMULATION
Let us assume that a single microphone input signal x(t) is modeled as where s(t) is a non-reverberant speech signal, h(t) is the Room Impulse Response (RIR) between the speaker and the microphone, * is the convolution operator and n(t) is an additive noise signal.
In the short-time Fourier transform (STFT) domain, the convolution is approximated as a multiplication operation, and (1) can be rewritten as, where l ∈ {0, . . . , L − 1} and f ∈ {0, . . . , F − 1} are the frame and frequency indexes, respectively. The term I(l) indicates the activity of s(l, f ) with, where Th is a pre-defined threshold applied on the clean signals.
The VAD goal is to accurately detect frames in which the speaker is active given a noisy reverberant signal, III. PROPOSED MODEL A block diagram of the proposed model is depicted in Fig. 1. The Mel-spectrum of the noisy input, x, is used as an input to our model. It is first propagates through a CNN, while preserving the input length dimension, L. The CNN 'embedder' takes the local spatial information of the input spectrum into account, and outputs frame-wise embedding, e(l). The embedding sequence, E = [e(0), . . . , e(L − 1)], is then fed into a SA encoder. The SA is responsible for calculating the attention of all other embedding with respect to e(l). Finally, a frame wise FC layer is used to estimate (4).

A. Self-attention encoder
SA mechanism [15] is at the core of prominent architectures in multiple Machine Learning domains such as Natural Language Processing (NLP) and Computer Vision (CV) [18], [20]. The main gits of the SA encoder is mapping a query and a set of key-value pairs to an output. The output is computed as a weighted sum of the values, where the weight assigned to each value is computed using the given query with the corresponding key. In our case, given the framewise embedding sequence E ∈ R d×L where L is the input sequence length and d is the dimension of each element of the sequence, a single layer attention of the multi-head attention with H attention heads is computed as are the learned parameter-sets of the multi-head attention layer.
The average attention ( across all H heads) from each frame to each other frame can be written as, Note, that the average attention dimensions are [L, L], connecting each frame information with all other frames.
After the self-attention layer, a residual connections and layer-norm are applied and then a feed-forward layer, which first increases the dimensions of each input vector from d to d f f , and then decreases it to the original size, followed by residual connections together with additional layer-norm.

B. Model Architecture
We construct a four layer CNN with batch-norm, PReLU non-linearly and max-polling between each of the convolution layers. The CNN output dimentions are [L, F , C], where F represents the remaining frequency dimension (after the pooling operations) and C represents the number of channels in the CNN output layer.
Frame-wise flattening operation is carried out to the output of the CNN. The remaining frequencies F and channels C, are flatten for each frame while preserving the frame dimension, meaning we get a [L, F ·C] embedding. We then use a framewise FC layer that transforms each embedding from size F ·C to size d, resulting in frame-wise embedding, E ∈ R d×L .
The SA encoder is then applied on the embedding sequence. The output of the SA encoder is also a sequence, but unlike the input sequence, the output sequence contains contextual information from the entire input. The output sequence passes through a frame-wise FC layer which finally detects the speech presence of each frame. A moving average is used for further smoothing of the model outputs.
As mentioned above, the Mel-spectrum is used as the input to the network, with window length of 1024 bins, and hop size of 512. With sample-rate of f s = 8 KHz, the frame and hop lengths are 128 and 64 ms, respectively. The number of Mel-filters was set to F = 256 and varying length L, resulting in a input size of L, F . In the CNN, we use a 3 × 3 kernels with C = 32 channels across all layers and we use a [2,1] max polling operation between each convolution layer. After 4 convolution layers we get F = 16, meaning after the framewise flattening operation we get a feature vector of length F · C = 512 for each frame, which is based not only of the single frame features, but also on features of proximate frames. In the encoder layer we set d = 256 and d f f = 512 with H = 16 heads and dropout of 0.1. With these parameter setting, the model is constructed with 560K trainable parameters, and wights only 5.5M B.

C. Training setup
We train our model using the Stochastic Gradient Descent (SGD) optimizer, which we found to be the best fit for this task. We use learning rate of 0.0003, weight decay of 1e −5 , batch size of 128 and use Spec Augment to prevent the model from over-fitting. We use Binary Cross Entropy (BCE) loss to train our model. In order to train our model with constant batch size, we construct training samples by randomly selecting 256 frames from sample of the original data. At inference time, the model operates on the entire sequence. In cases where the input length is too long, it could be split into shorter segments. In this section, we describe the experimental setup, including the train and test datasets, the experiments carried out, and the results.

A. Datasets
In order to train the proposed method we generated a supervised dataset to simulate various real-life scenarios according to (1). The LibriSpeech [21] dataset was used as a clean speech dataset. This is a relatively clean dataset and hence, a simple energy based VAD is used to label the dataset. Since the speech data in the LibriSpeech dataset is not balanced in terms of speech to non-speech ratio, the data was balanced by adding silence segments to the speech signals in random locations.
To simulate various RIRs, the RIRgenerator [22] was used with randomly chosen acoustic conditions, such as microphone and speaker positions,room dimensions, and reverberation level according to Table I. The additive noises were drawn from the WHAM! [23] corpus, which consist of babble noises recorded in different environments such as, restaurants, cafes, bars, and parks. We added the noises to the reverberant speech signal at random Signal to Noise Ratios (SNRs) in the range of [−3, 20] dB.
Finally, 30, 000 training scenarios were generated for the training dataset, 6, 500 for the validation and 6, 500 for the test datasets. Note, that the speakers and the noises were randomly divided prior to the generation of the datasets, to prevent leakage of the same speakers or noise between training, validation and test phases.

B. Experimental setup
Objective measurements We use the Area Under the Curve (AUC) of the Receiver Operating Characteristic (ROC), and the Equal Error Rate (EER) as evaluation metrics for our model. Compared methods We compared our model with 3 other models. The first is the boosted DNN (bDNN) [6] architecture, which uses an ensemble of DNNs, each with a different context length, to deal with the problem of a single fixed context length. The second is the ACAM [14] and the third is the SA [19], which were explained in the introduction. The parameter count for each of the models is summarized in Table  II.

C. Results
Real-life benchmark To test our model, two benchmarks are used. The first, recently published in [19], is constructed with real world MOVIE dataset, containing audio signals of 6 movies together with their corresponding VAD labels. The second, is the ENVIRONMENT test set [14]. This test set was recorded at 4 different environments including: park, bus-stop, construction-site and room. It is worth noting, that for a fair comparison, the reported results of the compared models are the ones which preformed better, on most of the test set in [19]. Furthermore, we emphasise that the compared methods are trained and evaluated with f s = 16 KHz, while our model is trained and evaluated with f s = 8 KHz by down-sampling the test sets to 8kHz. Table III shows the AUC results of the proposed method together with the 3 compared methods on the MOVIE (6 movies) and ENVIRONMENT (4 environments) test sets. The SA algorithm outperforms the ACAM and the bDNN methods. This states the benefit of this approach. It is further evident that our model, which combines the a CNN embedder before the SA encoder, gains even better results. Although our model is marginally larger than of the SA model, in inference time, our model is applied on the entire signal at once, while the SA model is applied on each frame separately. Ablation study The proposed algorithm consists of a CNN embedder and a SA encoder. In this section compare our model to 2 variants of the proposed architecture, the first is an end-to-end FCNN architecture, while the second (Encoder) is an end-to-end SA based encoders architecture. All models were trained with the same training dataset described in the previous section. The different variants were designed to have approximately the same number of parameters. Their parameter size are summarized in Table IV. As a test set for this experiment we used 3 testing sets. The first is the test set created from the Librispeech data set and the WHAM! noises described in the datasets section. The second is Disk 6 of the NIST dataset [24], commonly used for diarization of phone calls. The third is a testing set created using the Timit dataset [25], with the WHAM! noise test set, containing multiple speakers in each recording. All networks were designed to operate on 256 frames, and receive the same input, the Mel-spectrum. Although our model is able to operate on the entire sequence at once, and utilize the attention to benefit from the long context, for a fair comparison between the models we show the preference of the proposed model working on 256 frames at a time. We also apply the model on the entire input sequence to demonstrate the benefit of long context.
The EER and AUC results are summarized in Table V. Evidently, the combined architecture outperforms each of its individual components. Furthermore, using the entire input sequence outperforms the same model using 256 frames separately.
Finally, the ROC of the proposed model with its variants are depicted in 2. For a true-positive-rate at 0.98, marked with dashed red line, we show the advantage of the proposed method over its two variants.

Fig. 2: ROC on the Libri test set
Attention visualization To further evaluate the attention operation of the proposed architecture, a test sample from the LibriSpeech test-set is used. We visualize the average multihead attention wights (7) with respect to a speech frame, a noise frame and a transient noise frame. Fig. 3a depicts (7) for a speech frame. Fig. 3b for a noise frame, and Fig. 3c for a transient noise frame. In each Figure, the frame of interest is signed with a red rectangle on the Spectrogram, the black line plot represents (7) and the blue line plot represents the VAD true lable. Interestingly, for the speech frame, the encoder paid attention to frames in which speech was active, and vice-versa to noise only frames. It is evident that even 'far' speech is beneficial for the current speech frame.
For the noise frame, it is easy to see that since the noise is non-stationary and uncorrelated over time, the attention to all frames was low.
Finally, for the transient noise, it is evident that the highest attention was set to the same frame, since it is different than most other frames, noise and speech.

V. CONCLUSION
A CNN-SA architecture was presented for detecting speech given a noisy reverberant signal. CNN embedder is first used to exploit the spatial information of the input spectrum. The SA encoder is then applied on the frame-wise embedding sequence to gain contextual information. Finally, the model outputs the estimation of the presence of the speech. Experiments show that the proposed architecture outperforms end-to-end FCNN as well as SA architectures. The proposed method also achieve SOTA results on two real-life benchmarks.