Info

This question is closed. Reopen it to edit or answer.

i want to add keyboard voice to my voice. how i can add two audio waves? here no. of samples are 48000.. in this i am recieving an error that ??? Error using ==> vertcat CAT arguments dimensions are not consistent. how i can solve

2 views (last 30 days)
[y,fs,nbits]=wavread('C:\Users\HP\Desktop\anjali.wav');
sound(y,fs)
t=0:1/fs:length(y)/fs-1/fs;
%%%%%% keyboard noise
[z,fs,nbits]=wavread('C:\Users\HP\Desktop\keyboard.wav');
sound(z,fs)
t1=0:1/fs:length(z)/fs-1/fs;
%%%%%%%%%
y3 = [y(1:24000:); z; y(24000:end)];
sound(y3,fs)
t=0:1/fs:length(y)/fs-1/fs;
  2 Comments
Jan
Jan on 5 Apr 2013
Edited: Jan on 5 Apr 2013
I suggest to spend the time for reading the thread with the second most votes in this forum: http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency
Please learn how to format code properly in the forum to increase the readability. This would be a good idea, when you want to encourage others to read and understand your code.
Posting unrelated code is usually too confusing to be efficient. Does you problem have any relation to the plotting of the signals? If not, take the chance to edit your original question and remove the corresponding parts of the code, such that we can concentrate on the essential parts without excessive scrolling.
The unclear explanation of the problem and the bad layout of the question does not correlate to the claim, that this question is "urgent".
Jan
Jan on 5 Apr 2013
Edited: Jan on 5 Apr 2013
There is an additional ":" in the line
y3 = [y(1:24000:); z; y(24000:end)];
The bug is in exactly this line and a possible solution concerns additional colons in the indexing. Therefore this is a typo at a very important location, which should be fixed.

Answers (1)

Jan
Jan on 5 Apr 2013
The error message is clear:
vertcat CAT arguments dimensions are not consistent
This means, that the dimensions of y and z are not matching. And because you concatenate (not "add"!) them vertically, it must be the 2nd dimension. When the WAV-files are recoreded in stereo, the signals have two columns. But y(1:24000) replies a part of the first column only. Please try:
y3 = [y(1:24000, :); z; y(24000:end, :)];
If this fails also, check if both WAV files have the same number of channel, or in other word are both mono or stereo.
Using the debugger would reveal such problems easily and much faster than the forum: Set a breakpoint in the crashing line or let Matkab stop automatically when an error occurs:
dbstop if error
Then split the command into parts:
a = y(1:24000);
b = y(2400:end);
size(a)
size(b)
size(z)
  2 Comments
anjali parashar
anjali parashar on 7 Apr 2013
i want that when i speak, keyboard noise shoud also be there in between my voice. this is playing voices one by one. i want to show keyboard voice as a noise when i speak.
anjali parashar
anjali parashar on 7 Apr 2013
plz help me in the code . this code is concatenating the audio files. i want to merge these voices. like a person is speaking and he/she doing work on keyboard. then how this keyboard noise can be added to the voice of that person? its urgent.

This question is closed.

Community Treasure Hunt

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

Start Hunting!