Skip to content

The code computes the STFT of the audio signal using overlapping windows, and various features can be extracted from the resulting STFT matrix, which can then be used to train a machine learning model, such as an SVM, to classify the emotional state of the speaker.

License

Notifications You must be signed in to change notification settings

guillaumelauzier/emotional-xyz-soundwave

Repository files navigation

emotional-xyz-soundwave

In this example code, we create a sine wave with a fixed frequency of 440 Hz, and use an oscillator node to generate the sound. We then add a stereo panner node to control the horizontal positioning of the sound. We define a map function to map the user's input (voice pitch and emotion) to the vertical and depth positioning, respectively. We set the panner position based on these positions, and start the oscillator.

Note that this is a basic example and you may need to modify it to achieve the desired effect, such as by adding effects, adjusting the panning range or sensitivity, or using a more sophisticated synthesis method.


Speech Analysis .cpp

C++ code for speech analysis using the Fast Fourier Transform (FFT) algorithm to extract the frequency domain features of an audio signal. This code computes the Short-Time Fourier Transform (STFT) of an audio signal, which is a sequence of FFTs of short, overlapping segments of the signal. The resulting STFT matrix can be used to extract features such as pitch, intensity, and spectral shape, which can be used to detect emotional content.

The code uses the FFTW library to compute the FFTs of the audio signal. The computeSTFT() function takes the audio signal and the sample rate as input, and returns the STFT matrix as a vector of doubles. The STFT matrix is a two-dimensional array where each row represents a frequency band and each column represents a time window. The code computes the STFT using the overlapping window method, where consecutive windows overlap by 50%.

After computing the STFT matrix, you can extract features from it to detect emotional content. For example, you can compute the pitch of the signal by finding the frequency bin with the highest magnitude in each time window. You can also compute the spectral centroid, which is the weighted mean of the frequency bins in each time window. Other features that can be extracted include spectral rolloff, which is the frequency below which a certain percentage of the signal's energy is concentrated, and spectral flux, which measures the change in spectral shape between consecutive time windows. In addition to these features, a variety of other features can be computed from the STFT matrix, such as the spectral flatness, spectral contrast, and spectral entropy.

Once the features have been extracted, they can be used as input to a machine learning model to classify the emotional state of the speaker. One common approach is to use a support vector machine (SVM), which is a type of supervised learning algorithm that can be trained to classify data into different categories. In the case of speech analysis, the SVM can be trained to classify the speech signal into different emotional categories based on the extracted features.

In summary, speech analysis involves extracting features from the frequency domain representation of an audio signal, such as the STFT matrix. These features can be used to detect emotional content in the speech signal and classify it using machine learning algorithms. The resulting emotional analysis can have a variety of applications, such as improving speech recognition systems, detecting deception in speech, and monitoring the emotional state of individuals in various contexts.

About

The code computes the STFT of the audio signal using overlapping windows, and various features can be extracted from the resulting STFT matrix, which can then be used to train a machine learning model, such as an SVM, to classify the emotional state of the speaker.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published