About how to extract a speech signal's envelope

4 views (last 30 days)
Hello,
I had a question about extract a speech signal's envelope.
y=wavread('test.wav');
x=hilbert(y);
x1=abs(x);
x2=sqrt(x.*conj(x));
x1 and x2 are two different way that I had found on Google. Looks very similar but not equal (isequal(x1,x2)=0)
I don't know which one was right. and I had try some code about envelope detector on MATLAB file center, but the result seems not correct...
Thanks

Accepted Answer

Wayne King
Wayne King on 18 Feb 2013
Edited: Wayne King on 18 Feb 2013
Using the Hilbert transform is a better way to proceed than your
x2 = sqrt(x.*conj(x));
The above just gives the magnitude squared of each of the waveform values and that is not the envelope. At least probably not in the sense you mean envelope. To illustrate how the Hilbert transform does indeed extract the envelope, I'll give you a simple example with an AM-modulated wave.
Fs = 1000;
t = 0:0.001:1-0.001;
% 250-Hz sine wave modulated at 10 Hz
x = [1+cos(2*pi*10*t)].*cos(2*pi*250*t);
y = hilbert(x);
plot(t,x,'k'); hold on;
plot(t,abs(y),'b','linewidth',2);
plot(t,-abs(y),'b','linewidth',2);
If you know zoom in on parts of the waveform, you'll clearly see how the modulus of the analytic signal yields the envelope. Specifically, you see that the envelope oscillates at 10 Hz.
set(gca,'xlim',[0.05 0.35]);
set(gca,'ylim',[-2 2])
  1 Comment
Eason
Eason on 18 Feb 2013
Hi King,
Thanks for your answer, I use the code
>> y=wavread('h_006.wav');
>> x=hilbert(y);
>> upenv=abs(x);
>> lowenv=-abs(x);
>> plot(y);hold on;plot(upenv,'r');plot(lowenv,'r');
The result as figure.
And then there has another question, I need to create a 500 Hz sine wave which has same length and sampling rate as my speech file. And it also need to has same envelope of my speech file.
Fs=44100;%the sampling rate of speech file
dur=2.5;%the length of speech file
t=[0:1/Fs:dur-1/Fs];%time vector
freq=500;%sine wave's frequency
sin_wave=0.5*sin(2*pi*freq*t);%create sine wave
The code above was used to create a 500 Hz sine wave which has 2.5 sec long, sampling rate 44100 Hz, is that correct?
And how can I modulation sin_wave's envelope that was same as speech?
Thanks

Sign in to comment.

More Answers (1)

Wayne King
Wayne King on 18 Feb 2013
Yes, basically, although, I'm not sure why you set the amplitude equal to 0.5
For example:
load mtlb;
analmtlb = hilbert(mtlb);
t = 0:1/Fs:length(mtlb)*(1/Fs)-1/Fs;
x = cos(2*pi*500*t);
y = abs(analmtlb).*x';
soundsc(y,Fs)
  2 Comments
Eason
Eason on 18 Feb 2013
Very appreciate for your help.
The amplitude equal to 0.5 was a mistake.
Here is a little question about y=abs(analmtlb).*x';
y=envelope.*sine wave; is same as y=sine wave.*envelope?
or the latrer was incorrect way?
Thanks again.
Wayne King
Wayne King on 18 Feb 2013
yes, in my example, analmtlb was the analytic signal, so the absolute value is the envelope.

Sign in to comment.

Categories

Find more on Simulation, Tuning, and Visualization in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!