我在录制语音5秒钟时遇到问题。我已经使用play()函数成功回放了,但是一旦我播放了我保存在桌面上的wav文件,它就是沉默。 这是代码
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.');`enter code here`
% Play back the recording.
play(recObj);
myspeech = getaudiodata(recObj,'double');
wavwrite(double(myspeech),'C://Users//naveen//Desktop//unprocessed')
% Store data in double-precision array.
myRecording = getaudiodata(recObj);
% Plot the samples.
figure,plot(myRecording),title('Original Sound');
答案 0 :(得分:1)
wavwrite
时不指定采样率,默认值为8000Hz
然而,在您致电audiorecorder
audiorecorder(96000, 16, 1);
将这两个更改为匹配应修复此问题,因此请将以下任一调用更改为
recObj = audiorecorder(8000, 16, 1)
wavwrite(double(myspeech),96000,'C:/...snip...
作为补充说明,我认为myspeech
已经加倍(如getaudiodata
中所述)
所以wavwrite(myspeech,96000,'C:/...snip...
应该也能正常工作!