Skip to content

Commit 4e45cc9

Browse files
fix(nemo-speech-cpp): build required sentencepiece
The updated runtime uses SentencePiece for RNNT context biasing even when Flashlight and text normalization are disabled. Build upstream's pinned static archive before configuring the engine so every backend variant has the newly required library and headers. Assisted-by: Codex:gpt-5
1 parent 5c94d30 commit 4e45cc9

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

backend/go/nemo-speech-cpp/Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ ITN_LIB_DIR=$(ITN_PREFIX)/lib
8888
ITN_MARKER=$(ITN_LIB_DIR)/libsparrowhawk.so
8989
ITN_FST_HEADER=$(ITN_PREFIX)/include/fst/fst.h
9090

91+
# SentencePiece became a core ASR dependency in 5be7bfb: RNNT context biasing
92+
# uses it even when Flashlight and text normalization are disabled. Build the
93+
# pinned static archive provided by upstream so every platform gets the same
94+
# dependency instead of relying on an undeclared system package.
95+
SENTENCEPIECE_PREFIX=sources/NeMo-Speech.cpp/.deps/sentencepiece
96+
SENTENCEPIECE_MARKER=$(SENTENCEPIECE_PREFIX)/lib/libsentencepiece.a
97+
98+
# Linux's ASR CMake block looks in NEMO_SPEECH_DEPENDENCY_PREFIX directly, but
99+
# the Apple branch uses generic find_library()/find_path(). Put the same private
100+
# prefix on CMake's search path so Darwin consumes the archive built above too.
101+
CMAKE_ARGS+=-DCMAKE_PREFIX_PATH=$(abspath $(SENTENCEPIECE_PREFIX))
102+
91103
ITN_CC?=gcc-12
92104
ITN_CXX?=g++-12
93105

@@ -152,7 +164,7 @@ else
152164
endif
153165
CMAKE_ARGS+=-DNEMO_SPEECH_GGML_PATCHED=$(GGML_PATCHED)
154166

155-
.PHONY: nemo-speech-cpp-grpc package build clean purge test all stage-libs patch-ggml engine itn patch-itn-headers
167+
.PHONY: nemo-speech-cpp-grpc package build clean purge test all stage-libs patch-ggml engine itn sentencepiece patch-itn-headers
156168

157169
all: nemo-speech-cpp-grpc package
158170

@@ -266,11 +278,17 @@ patch-itn-headers:
266278

267279
itn: $(ITN_MARKER)
268280

281+
$(SENTENCEPIECE_MARKER): | sources/NeMo-Speech.cpp
282+
cd sources/NeMo-Speech.cpp && JOBS=$(JOBS) scripts/build_sentencepiece_static.sh
283+
284+
sentencepiece: $(SENTENCEPIECE_MARKER)
285+
269286
# Only a WITH_NORM=ON build needs the ITN stack, and it must exist before cmake
270287
# configures, since the WITH_NORM cmake block find_library()s into the prefix
271288
# with REQUIRED.
289+
NEMO_RUNTIME_PREREQS=$(SENTENCEPIECE_MARKER)
272290
ifeq ($(WITH_NORM),ON)
273-
NEMO_RUNTIME_PREREQS=$(ITN_MARKER)
291+
NEMO_RUNTIME_PREREQS+=$(ITN_MARKER)
274292
endif
275293

276294
# Upstream sets CMAKE_LIBRARY_OUTPUT_DIRECTORY to ${CMAKE_BINARY_DIR}/bin, so the

0 commit comments

Comments
 (0)