diff --git a/backend/go/nemo-speech-cpp/Makefile b/backend/go/nemo-speech-cpp/Makefile index 9ec3431492ec..7eac899dfeb8 100644 --- a/backend/go/nemo-speech-cpp/Makefile +++ b/backend/go/nemo-speech-cpp/Makefile @@ -12,7 +12,7 @@ # runs 'make -C backend/go/$(BACKEND) build' and then copies package/), so it # has to produce the binary and the package, not just the shared libraries. -NEMO_SPEECH_VERSION?=2e12e2def8a98ed06666f7ee3ca94e7193e04be4 +NEMO_SPEECH_VERSION?=9bc876635af36df537d9bc6d3f57ad1b76e4f74a NEMO_SPEECH_REPO?=https://github.com/NVIDIA/NeMo-Speech.cpp GOCMD?=go @@ -88,6 +88,18 @@ ITN_LIB_DIR=$(ITN_PREFIX)/lib ITN_MARKER=$(ITN_LIB_DIR)/libsparrowhawk.so ITN_FST_HEADER=$(ITN_PREFIX)/include/fst/fst.h +# SentencePiece became a core ASR dependency in 5be7bfb: RNNT context biasing +# uses it even when Flashlight and text normalization are disabled. Build the +# pinned static archive provided by upstream so every platform gets the same +# dependency instead of relying on an undeclared system package. +SENTENCEPIECE_PREFIX=sources/NeMo-Speech.cpp/.deps/sentencepiece +SENTENCEPIECE_MARKER=$(SENTENCEPIECE_PREFIX)/lib/libsentencepiece.a + +# Linux's ASR CMake block looks in NEMO_SPEECH_DEPENDENCY_PREFIX directly, but +# the Apple branch uses generic find_library()/find_path(). Put the same private +# prefix on CMake's search path so Darwin consumes the archive built above too. +CMAKE_ARGS+=-DCMAKE_PREFIX_PATH=$(abspath $(SENTENCEPIECE_PREFIX)) + ITN_CC?=gcc-12 ITN_CXX?=g++-12 @@ -152,7 +164,7 @@ else endif CMAKE_ARGS+=-DNEMO_SPEECH_GGML_PATCHED=$(GGML_PATCHED) -.PHONY: nemo-speech-cpp-grpc package build clean purge test all stage-libs patch-ggml engine itn patch-itn-headers +.PHONY: nemo-speech-cpp-grpc package build clean purge test all stage-libs patch-ggml engine itn sentencepiece patch-itn-headers all: nemo-speech-cpp-grpc package @@ -266,11 +278,27 @@ patch-itn-headers: itn: $(ITN_MARKER) +$(SENTENCEPIECE_MARKER): | sources/NeMo-Speech.cpp + # The pinned helper uses GNU install's -D option, which BSD install on macOS + # does not support. Create the directory explicitly and keep the helper's + # four license installs otherwise unchanged. +ifeq ($(shell uname -s),Darwin) + mkdir -p $(SENTENCEPIECE_PREFIX)/share/licenses/nemo-speech/third_party/sentencepiece + sed -i.bak \ + -e 's/install -Dm0644/install -m 0644/' \ + -e 's/-DCMAKE_BUILD_TYPE=Release \\/-DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \\/' \ + sources/NeMo-Speech.cpp/scripts/build_sentencepiece_static.sh +endif + cd sources/NeMo-Speech.cpp && JOBS=$(JOBS) scripts/build_sentencepiece_static.sh + +sentencepiece: $(SENTENCEPIECE_MARKER) + # Only a WITH_NORM=ON build needs the ITN stack, and it must exist before cmake # configures, since the WITH_NORM cmake block find_library()s into the prefix # with REQUIRED. +NEMO_RUNTIME_PREREQS=$(SENTENCEPIECE_MARKER) ifeq ($(WITH_NORM),ON) -NEMO_RUNTIME_PREREQS=$(ITN_MARKER) +NEMO_RUNTIME_PREREQS+=$(ITN_MARKER) endif # Upstream sets CMAKE_LIBRARY_OUTPUT_DIRECTORY to ${CMAKE_BINARY_DIR}/bin, so the