sherpa-ncnn-wasm-main.cc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * Copyright (c) 2024 Xiaomi Corporation (authors: Fangjun Kuang)
  3. *
  4. * See LICENSE for clarification regarding multiple authors
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include <algorithm>
  19. #include <memory>
  20. #include "sherpa-ncnn/c-api/c-api.h"
  21. // see also
  22. // https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html
  23. extern "C" {
  24. static_assert(sizeof(SherpaNcnnFeatureExtractorConfig) == 4 * 2, "");
  25. static_assert(sizeof(SherpaNcnnModelConfig) == 4 * 9, "");
  26. static_assert(sizeof(SherpaNcnnDecoderConfig) == 4 * 2, "");
  27. static_assert(sizeof(SherpaNcnnRecognizerConfig) ==
  28. 4 * 2 + 4 * 9 + 4 * 2 + 4 * 4 + 4 * 2,
  29. "");
  30. void CopyHeap(const char *src, int32_t num_bytes, char *dst) {
  31. std::copy(src, src + num_bytes, dst);
  32. }
  33. }