フィルターのクリア

Audio file (.wav) being overwritten

5 ビュー (過去 30 日間)
LearningMatLab
LearningMatLab 2019 年 8 月 10 日
コメント済み: Walter Roberson 2019 年 8 月 13 日
I find that if I run the code that the audio file becomes overwritten so I then need to reload the original data into the directory .
What should I do ?
% y= Audio data
% Fs = Sample rate
% How to read the first "2" seconds
% samples = [1,2*Fs];
% clear y Fs
% [y,Fs] =audioread(filename,samples);
clear
clc
speech = ('coch4.wav');
speech2 = speech;
[y,Fs]=audioread(speech2); %don't use wavread or audioread
audiowrite(speech, speech_trimmed, 44100);
% Q1 a)
speechL = speech(:,1); % Should hear "Sometimes I whisper quietly and sometimes I shout very,very loud"
speechR = speech(:,2); % just noise
disp(Fs);
%Q1 b)
% Q1 c)
n = size(speech);
% Q1 d) https://au.mathworks.com/matlabcentral/answers/223670-how-can-i-change-the-sampling-frequency-of-audio-signal
Fs4 = Fs/4;
audiowrite(speech,speech_trimmed,Fs4);
[y,Fs4]=audioread(speech);
n2 = size(speech);

採用された回答

Walter Roberson
Walter Roberson 2019 年 8 月 10 日
You have
speech = ('coch4.wav');
speech2 = speech;
So your speech2 filename is the same as your speech filename.
[y,Fs]=audioread(speech2); %don't use wavread or audioread
So you read from coch4.wav via speech2 filename
audiowrite(speech, speech_trimmed, 44100);
and then you write to the file name given by speech, which is the same as the filename given by speech2, so you are writing to the same file that you read the data from.
  5 件のコメント
LearningMatLab
LearningMatLab 2019 年 8 月 13 日
So 'choc4_2sec.wav' and 'choc4_slower.wav' are audio files that become created from the audiowrite() ?
Walter Roberson
Walter Roberson 2019 年 8 月 13 日
Yes.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by