Effacer les filtres
Effacer les filtres

Audio file (.wav) being overwritten

5 vues (au cours des 30 derniers jours)
LearningMatLab
LearningMatLab le 10 Août 2019
Commenté : Walter Roberson le 13 Août 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);

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by