|On this page…|
Spectrograms are color-based visualizations of the evolution of the power spectrum of a speech signal as this signal is swept through time. Spectrograms use the periodogram power spectrum estimation method and are widely used by speech and audio engineers. You can use them to develop a visual understanding of the frequency content of your speech signal while a particular sound is being vocalized.
In the previous section, you built a model capable of calculating the power spectrum of a speech signal that represents a woman saying "MATLAB." In this topic, you modify this model to view the spectrogram of your signal:
If the model you created in View the Power Spectrum Estimates is not open on your desktop, you can open an equivalent model by typing
at the MATLAB® command prompt.
Simulink / Signal Routing
Math Functions / Math Operations
Signal Management / Buffers
Simulink / Math Operations
Connect the blocks as shown in the figure below. These blocks extract the positive frequencies of each power spectrum and concatenate them into a matrix that represents the spectrogram of the speech signal.
Once you have assembled the blocks needed to view the spectrogram of your speech signal, you can set the block parameters.
In the previous topic, you assembled the blocks you need to view the spectrogram of your speech signal. Now you must set the block parameters:
If the model you created in Modify the Block Diagram is not open on your desktop, you can open an equivalent model by typing
at the MATLAB command prompt.
Use the Selector block to extract the first 64 elements, or the positive frequencies, of each power spectrum. Open the Selector dialog box by double-clicking the block. Set the block parameters as follows:
Number of input dimensions = 1
Index mode = One-based
Index option = Index vector (dialog)
Index = 1:64
Input port size = 128
At each time instance, the input to the Selector block is a vector of 128 elements. The block assigns one-based indices to these elements and extracts the first 64. Once you are done setting these parameters, the Selector dialog box should look similar to the figure below. To apply your changes, click OK.
Output buffer size (per channel) = 64*48
Buffer overlap = 64*46
Initial conditions = -70
Treat Mx1 and unoriented sample-based signals as = One channel
Once you are done setting these parameters, the Buffer1 dialog box should look similar to the following figure. To apply your changes, click OK.
Setting the value of the Buffer overlap parameter slightly less than the value of the Output buffer size (per channel) parameter ensures that your spectrogram represents smooth movement through time. The Initial conditions parameter represents the initial values in the buffer; -70 represents silence.
Click the Image Properties tab.
Colormap matrix = jet(256)
Minimum input value = -150
Maximum input value = -65
Select the Display colorbar check box.
Once you are done setting these parameters, the Image Properties pane should look similar to the figure below.
Click the Axis Properties tab.
Axis origin = Lower left corner
X-axis title = Time Index
Y-axis title = Frequency Index
Colorbar title = dB Magnitude
In this case, you are assuming that the power spectrum values do not exceed -65 dB. Once you are done setting these parameters, the Axis Properties pane should look similar to the figure below. To apply your changes, click OK.
After you have set the parameter values, you can calculate and view the spectrogram of the speech signal.
In the topic View the Power Spectrum Estimates, you used a Vector Scope block to display the power spectrum of your speech signal. In this topic, you view the spectrogram of your speech signal using a Matrix Viewer block. The speech signal represents a woman's voice saying "MATLAB":
If the model you created in Set the Model Parameters is not open on your desktop, you can open an equivalent model by typing
at the MATLAB command prompt.
Run the model. During the simulation, the Vector Scope window displays a sequence of power spectrums, one for each window of the original speech signal. The power spectrum is the contribution of every frequency to the power of the speech signal.
The Matrix Viewer window, shown below, displays the spectrogram of the speech signal. This spectrogram is calculated using the Periodogram power spectrum estimation method. Note the harmonics that are visible in the signal when the vowels are spoken. Most of the signal's energy is concentrated in these harmonics; therefore, two distinct peaks are visible in the spectrogram.
In this example, you viewed the spectrogram of your speech signal using a Matrix Viewer block. You can find additional DSP System Toolbox™ product examples in the Help browser. To access these examples, click the Contents tab, double-click DSP System Toolbox, and then click Examples. A list of the examples in the DSP System Toolbox documentation appears in the right pane of the Help browser.