Skip to content
Permalink
Browse files

eml_audio: Better checks in melspectrogram()

  • Loading branch information...
jonnor committed Dec 29, 2018
1 parent 1f302f9 commit 6340f7dcf08c2e0b29876c21079a298423bc96e3
Showing with 8 additions and 3 deletions.
  1. +8 −3 bindings/eml_audio.cpp
@@ -64,6 +64,10 @@ melspectrogram_py(py::array_t<float, py::array::c_style | py::array::forcecast>
throw std::runtime_error("spectrogram input must have dimensions 1");
}

if (in.shape(0) != n_fft) {
throw std::runtime_error("melspectrogram framing not implented");
}

// FFT table
const int n_fft_table = n_fft/2;
std::vector<float> fft_sin(n_fft_table);
@@ -81,11 +85,12 @@ melspectrogram_py(py::array_t<float, py::array::c_style | py::array::forcecast>
EmlVector tempv = { (float *)temp.data(), length };
EmlVector inv = {(float *)in.data(), length};
eml_vector_set(inoutv, inv, 0);
eml_vector_set_value(tempv, 0);

const int status = eml_audio_melspectrogram(params, fft, inoutv, tempv);
const EmlError error = eml_audio_melspectrogram(params, fft, inoutv, tempv);

if (status != 0) {
throw std::runtime_error("melspectrogram returned error: " + std::to_string(status));
if (error != EmlOk) {
throw std::runtime_error("melspectrogram returned error: " + std::string(eml_error_str(error)));
}

auto ret = py::array_t<float>(params.n_mels);

0 comments on commit 6340f7d

Please sign in to comment.
You can’t perform that action at this time.