From 5bea3bc1282dead7f1f227aede3d8a2805daa4ff Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Thu, 8 May 2025 16:10:42 +0800 Subject: [PATCH 1/2] Fix building wheels for macos --- .github/workflows/build-wheels-macos-universal2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wheels-macos-universal2.yaml b/.github/workflows/build-wheels-macos-universal2.yaml index 0f9dcedc78..4929bf6526 100644 --- a/.github/workflows/build-wheels-macos-universal2.yaml +++ b/.github/workflows/build-wheels-macos-universal2.yaml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest] + os: [macos-13] python-version: ["cp38", "cp39", "cp310", "cp311", "cp312", "cp313"] steps: From 07e6ea51106141debf79ee8516a53d878df3edb0 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Thu, 8 May 2025 16:13:56 +0800 Subject: [PATCH 2/2] output more verbose logs --- .../workflows/build-wheels-macos-universal2.yaml | 10 ++++++++-- sherpa-onnx/csrc/file-utils.cc | 2 +- sherpa-onnx/csrc/keyword-spotter-transducer-impl.h | 13 +++++++------ .../csrc/offline-recognizer-transducer-impl.h | 6 +++--- sherpa-onnx/csrc/wave-writer.cc | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-wheels-macos-universal2.yaml b/.github/workflows/build-wheels-macos-universal2.yaml index 4929bf6526..68998f7782 100644 --- a/.github/workflows/build-wheels-macos-universal2.yaml +++ b/.github/workflows/build-wheels-macos-universal2.yaml @@ -88,7 +88,13 @@ jobs: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python3 -m pip install --break-system-packages --upgrade pip - python3 -m pip install --break-system-packages wheel twine==5.0.0 setuptools + opts='--break-system-packages' + v=${{ matrix.python-version }} + if [[ $v == cp38 || $v == cp39 ]]; then + opts='' + fi + + python3 -m pip install $opts --upgrade pip + python3 -m pip install $opts wheel twine==5.0.0 setuptools twine upload ./wheelhouse/*.whl diff --git a/sherpa-onnx/csrc/file-utils.cc b/sherpa-onnx/csrc/file-utils.cc index 1bd8e584af..adbc161866 100644 --- a/sherpa-onnx/csrc/file-utils.cc +++ b/sherpa-onnx/csrc/file-utils.cc @@ -35,7 +35,7 @@ std::vector ReadFile(AAssetManager *mgr, const std::string &filename) { AAsset *asset = AAssetManager_open(mgr, filename.c_str(), AASSET_MODE_BUFFER); if (!asset) { __android_log_print(ANDROID_LOG_FATAL, "sherpa-onnx", - "Read binary file: Load %s failed", filename.c_str()); + "Read binary file: Load '%s' failed", filename.c_str()); exit(-1); } diff --git a/sherpa-onnx/csrc/keyword-spotter-transducer-impl.h b/sherpa-onnx/csrc/keyword-spotter-transducer-impl.h index e62b3b2c07..a207be115c 100644 --- a/sherpa-onnx/csrc/keyword-spotter-transducer-impl.h +++ b/sherpa-onnx/csrc/keyword-spotter-transducer-impl.h @@ -123,9 +123,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl { if (!EncodeKeywords(is, sym_, ¤t_ids, ¤t_kws, ¤t_scores, ¤t_thresholds)) { #if __OHOS__ - SHERPA_ONNX_LOGE("Encode keywords %{public}s failed.", keywords.c_str()); + SHERPA_ONNX_LOGE("Encode keywords '%{public}s' failed.", + keywords.c_str()); #else - SHERPA_ONNX_LOGE("Encode keywords %s failed.", keywords.c_str()); + SHERPA_ONNX_LOGE("Encode keywords '%s' failed.", keywords.c_str()); #endif return nullptr; } @@ -303,10 +304,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl { std::ifstream is(config_.keywords_file); if (!is) { #if __OHOS__ - SHERPA_ONNX_LOGE("Open keywords file failed: %{public}s", + SHERPA_ONNX_LOGE("Open keywords file failed: '%{public}s'", config_.keywords_file.c_str()); #else - SHERPA_ONNX_LOGE("Open keywords file failed: %s", + SHERPA_ONNX_LOGE("Open keywords file failed: '%s'", config_.keywords_file.c_str()); #endif exit(-1); @@ -325,10 +326,10 @@ class KeywordSpotterTransducerImpl : public KeywordSpotterImpl { if (!is) { #if __OHOS__ - SHERPA_ONNX_LOGE("Open keywords file failed: %{public}s", + SHERPA_ONNX_LOGE("Open keywords file failed: '%{public}s'", config_.keywords_file.c_str()); #else - SHERPA_ONNX_LOGE("Open keywords file failed: %s", + SHERPA_ONNX_LOGE("Open keywords file failed: '%s'", config_.keywords_file.c_str()); #endif exit(-1); diff --git a/sherpa-onnx/csrc/offline-recognizer-transducer-impl.h b/sherpa-onnx/csrc/offline-recognizer-transducer-impl.h index 2f7c5bed1f..e275e75cc0 100644 --- a/sherpa-onnx/csrc/offline-recognizer-transducer-impl.h +++ b/sherpa-onnx/csrc/offline-recognizer-transducer-impl.h @@ -156,7 +156,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl { std::vector current_scores; if (!EncodeHotwords(is, config_.model_config.modeling_unit, symbol_table_, bpe_encoder_.get(), ¤t, ¤t_scores)) { - SHERPA_ONNX_LOGE("Encode hotwords failed, skipping, hotwords are : %s", + SHERPA_ONNX_LOGE("Encode hotwords failed, skipping, hotwords are : '%s'", hotwords.c_str()); } @@ -252,7 +252,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl { std::ifstream is(config_.hotwords_file); if (!is) { - SHERPA_ONNX_LOGE("Open hotwords file failed: %s", + SHERPA_ONNX_LOGE("Open hotwords file failed: '%s'", config_.hotwords_file.c_str()); exit(-1); } @@ -276,7 +276,7 @@ class OfflineRecognizerTransducerImpl : public OfflineRecognizerImpl { std::istringstream is(std::string(buf.begin(), buf.end())); if (!is) { - SHERPA_ONNX_LOGE("Open hotwords file failed: %s", + SHERPA_ONNX_LOGE("Open hotwords file failed: '%s'", config_.hotwords_file.c_str()); exit(-1); } diff --git a/sherpa-onnx/csrc/wave-writer.cc b/sherpa-onnx/csrc/wave-writer.cc index bbcd6e1655..f3aca8e90c 100644 --- a/sherpa-onnx/csrc/wave-writer.cc +++ b/sherpa-onnx/csrc/wave-writer.cc @@ -78,12 +78,12 @@ bool WriteWave(const std::string &filename, int32_t sampling_rate, WriteWave(buffer.data(), sampling_rate, samples, n); std::ofstream os(filename, std::ios::binary); if (!os) { - SHERPA_ONNX_LOGE("Failed to create %s", filename.c_str()); + SHERPA_ONNX_LOGE("Failed to create '%s'", filename.c_str()); return false; } os << buffer; if (!os) { - SHERPA_ONNX_LOGE("Write %s failed", filename.c_str()); + SHERPA_ONNX_LOGE("Write '%s' failed", filename.c_str()); return false; } return true;