Azzera filtri
Azzera filtri

Audio file (.wav) being overwritten

5 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by