Oct-27-2020, 01:11 PM
Hi all!
I am working on a sound classification project. I have written codes in Matlab, but I need to convert it into Python to use with Raspberry Pi. However, I am not very experienced in Python, so I could not convert some parts of the code.
Here is the Matlab version of the code;
"
clc
close all
load output.mat
d=2*44100;
m=1;
for i=2:41
C1=output{i,1};
r= floor(size(C1,1)/d);
for j=1:r
C1_Data(m,:)=C1(1+((j-1)*d):(d+((j-1)*d)));
m=m+1;
end
"
Here is the Python version which is created by me. However, I could not avoid errors.
"
output = np.concatenate((a1,a2,a3,a4,a5,a6,a7,a8,a9))
d=244100
m=1
C1_Data = pd.DataFrame(reweightTarget, columns = ('Sound Class'))
for i in range(0,43):
C1 = output[i][0]
r = math.floor(C1.size/d)
for j in range (1,r):
s=C1[1+((j-1)d):(d+((j-1)*d))]
C1_Data.loc[m]=[s]
m +=1 "
The error
"index(...) must be called with a collection of some kind 'Sound Class' was passed"
If you can help me solve the problem, I will be grateful.
I am working on a sound classification project. I have written codes in Matlab, but I need to convert it into Python to use with Raspberry Pi. However, I am not very experienced in Python, so I could not convert some parts of the code.
Here is the Matlab version of the code;
"
clc
close all
load output.mat
d=2*44100;
m=1;
for i=2:41
C1=output{i,1};
r= floor(size(C1,1)/d);
for j=1:r
C1_Data(m,:)=C1(1+((j-1)*d):(d+((j-1)*d)));
m=m+1;
end
"
Here is the Python version which is created by me. However, I could not avoid errors.
"
output = np.concatenate((a1,a2,a3,a4,a5,a6,a7,a8,a9))
d=244100
m=1
C1_Data = pd.DataFrame(reweightTarget, columns = ('Sound Class'))
for i in range(0,43):
C1 = output[i][0]
r = math.floor(C1.size/d)
for j in range (1,r):
s=C1[1+((j-1)d):(d+((j-1)*d))]
C1_Data.loc[m]=[s]
m +=1 "
The error
"index(...) must be called with a collection of some kind 'Sound Class' was passed"
If you can help me solve the problem, I will be grateful.