pythor 脚本返回 2d 'float64' numpy 数组。当我尝试将它分配给java中的'double'数组时,我收到此错误“java.lang.ClassCastException:TypeError:无法将float64对象转换为double []”
编辑
import librosa as lb
import numpy as np
from os.path import dirname, join
def build_feat(fpath):
filename = join(dirname(__file__), fpath)
wav, rate = lb.load(filename, sr=4000)
X_sample = lb.feature.mfcc(wav, sr=rate, n_fft=512, win_length=400, n_mfcc=20,
hop_length = 256, n_mels = 128, fmin = 100, fmax = 1800)
X = X_sample.T
return X
Java代码:
PyObject pyobj = py.getModule("featureExtraction");
PyObject obj = pyobj.callAttr("build_feat","107_2b4_Pl_mc_AKGC417L_0.wav");
double[][] feat = obj.toJava(double[][].class);
对于相同的代码,我现在得到一个不同的错误:com.chaquo.python.PyException: ValueError: ndarray is not contiguous