java 时域_如何将语音频谱转换为时域

本文介绍了如何进行语音分析,通过录制5秒声音,应用汉明窗、直流偏移消除和归一化后,使用FFT获取频谱。接着探讨如何将经过FFT处理的频谱数据转换回时域,以便观察声音的变化。
摘要由CSDN通过智能技术生成

我正在做语音分析 . 我录制了5秒的声音 . 应用汉明窗,直流偏移和归一化以及使用fft取得了光谱 . 我想知道声音有多大变化 . 那么有没有办法将fft转换回时域?

clc,clear;

% Record your voice for 5 seconds.

%recObj = audiorecorder;

recObj = audiorecorder(96000, 16, 1);

disp('Start speaking.')

recordblocking(recObj,5);

disp('End of Recording.');

% Play back the recording.

play(recObj);

get(recObj);

myspeech = getaudiodata(recObj);

wavwrite(double(myspeech),96000,'C://Users//naveen//Desktop//unprocessed')

% Store data in double-precision array.

myRecording = getaudiodata(recObj);

% Store data in double-precision array.

myRecording = getaudiodata(recObj);

% Plot the samples.

figure,plot(myRecording),title('Original Sound');

%Offset Elimination

a = myRecording;

a=double(a);

D = a-mean(a);

figure,plot(myRecording),title('Sound after Offset Elimination');

%normalizing

w = D/max(abs(D));

figure,plot(w),title('Normalized Sound');

% hamming window

a1=double(w);

%a1=a1';

N=length(w);

hmw = hamming(N);

temp = a1.*hmw;

a1 = temp;

%Fast Fourier Transform

a2=double(a1);

N=length(a1);

n=ceil(log2(N));

nz=2^n;

fs = 96000;

x_z=0*[1:nz];

x_z(1:N)=a2;

X=fft(x_z);

x1=abs(X);

wq=double(0:nz-1)*(fs/nz);

figure,stem(wq,x1),title('Spectrum');

xlabel('Frequency (Hz)');

ylabel('Magnitude of FFT Coefficients');

nz1=round(nz/2)

x2=x1(1:nz1);

w1=wq(1:nz1);

figure,plot(w1,x2);

title('Half Length Spectrum of Sound');

nz2=nz1*10;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值