ValueError: операнды не могут быть переданы вместе с фигурами (83,10) (7,) - PullRequest
0 голосов
/ 16 марта 2019

Ошибка в этой строке

 ps_test = [m.transform(observation) for m in ms]

Код (частичная часть)

transform funciton-
def transform(self, obs):
if len(obs.shape) == 2:
            B = self._state_likelihood(obs)
            log_likelihood, _ = self._forward(B)
            return log_likelihood
        elif len(obs.shape) == 3:
            count = obs.shape[0]
            out = np.zeros((count,))
            for n in range(count):
                B = self._state_likelihood(obs[n, :, :])
                log_likelihood, _ = self._forward(B)
                out[n] = log_likelihood
            return out

Ошибка в этой части -

new_data = np.zeros(9600)
maxsize = 755260
_, new_d = wavfile.read(r"C:\Users\Kanika Bansalwal\AppData\Local\Programs\Python\Python36\audio1\apple\apple01.wav")
print(new_d.shape[0])
new_data = np.zeros(new_d.shape[0])
new_data[:new_d.shape[0]] = new_d

new_data = new_data[:maxsize]

observation = []

new_d = np.abs(stft(new_data))
n_dim = 10
new_obs = np.zeros((n_dim, new_d.shape[0]))
for r in range(new_d.shape[0]):
    _, t = peakfind(new_d[r, :], n_peaks=n_dim)
    new_obs[:, r] = t.copy()
observation.append(new_obs)

observation = np.atleast_3d(observation)
observation /= observation.sum(axis=1)
**ps_test = [m.transform(observation) for m in ms]**
res_test = np.vstack(ps_test)
test_predicted_label = np.argmax(res_test, axis=0)
word_spoken = dictionary[test_predicted_label]
print (word_spoken)

Вся ссылка на код: https://github.com/prakashpandey9/IsolatedSpeechRecognition/blob/master/Isolated_Speech_Recognition.py

...