Filter löschen
Filter löschen

Audio file (.wav) being overwritten

5 Ansichten (letzte 30 Tage)
LearningMatLab
LearningMatLab am 10 Aug. 2019
Kommentiert: Walter Roberson am 13 Aug. 2019
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);

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 10 Aug. 2019
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 Kommentare
LearningMatLab
LearningMatLab am 13 Aug. 2019
So 'choc4_2sec.wav' and 'choc4_slower.wav' are audio files that become created from the audiowrite() ?
Walter Roberson
Walter Roberson am 13 Aug. 2019
Yes.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by