Repository navigation
Simplify RNNT ASR samples and remove Python inference bindings #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
contentis
wants to merge
5
commits into
main
Choose a base branch
from
simplify-rnnt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5a6cd1d
Simplify RNNT ASR samples and remove Python inference bindings
contentis ea6e591
Run ASR helper tests in the existing NVIDIA ASR workflow
contentis a066881
Keep existing model CI without additional unit-test steps
contentis 604e513
Pin both RNNT exporters to the existing NeMo v3.0.0 release
contentis 6c1f622
Keep shared ModelOpt extra and restore dtype after attention replacement
contentis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| add_library(din_asr_common INTERFACE) | ||
| target_include_directories(din_asr_common INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <algorithm> | ||
| #include <chrono> | ||
| #include <cstdint> | ||
| #include <cstdlib> | ||
| #include <filesystem> | ||
| #include <fstream> | ||
| #include <functional> | ||
| #include <initializer_list> | ||
| #include <iostream> | ||
| #include <memory> | ||
| #include <numeric> | ||
| #include <span> | ||
| #include <sstream> | ||
| #include <stdexcept> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| namespace din::asr::common | ||
| { | ||
|
|
||
| // --- file helpers -------------------------------------------------------- | ||
|
|
||
| inline std::string ReadText(const std::string& path) | ||
| { | ||
| std::ifstream stream(path); | ||
| if (!stream) | ||
| { | ||
| throw std::runtime_error("failed to open: " + path); | ||
| } | ||
| std::ostringstream buffer; | ||
| buffer << stream.rdbuf(); | ||
| return buffer.str(); | ||
| } | ||
|
|
||
| inline std::string RequirePath(const std::filesystem::path& path, std::string_view name) | ||
| { | ||
| if (!std::filesystem::exists(path)) | ||
| { | ||
| throw std::runtime_error("missing " + std::string{name} + ": " + path.string()); | ||
| } | ||
| return path.string(); | ||
| } | ||
|
|
||
| inline std::vector<float> ReadFloatFile(const std::filesystem::path& path) | ||
| { | ||
| std::ifstream stream(path, std::ios::binary); | ||
| if (!stream) | ||
| { | ||
| return {}; | ||
| } | ||
| stream.seekg(0, std::ios::end); | ||
| const auto size = stream.tellg(); | ||
| stream.seekg(0, std::ios::beg); | ||
| std::vector<float> values(static_cast<size_t>(size) / sizeof(float)); | ||
| stream.read(reinterpret_cast<char*>(values.data()), size); | ||
| return values; | ||
| } | ||
|
|
||
| // --- timing helper ------------------------------- | ||
|
|
||
| inline double SecondsSince(std::chrono::steady_clock::time_point start) | ||
| { | ||
| return std::chrono::duration<double>(std::chrono::steady_clock::now() - start).count(); | ||
| } | ||
|
|
||
| // --- Shared command-line front end -------------------------------------- | ||
|
|
||
| struct TranscriptionOptions | ||
| { | ||
| std::string timestamps = "none"; | ||
| }; | ||
|
|
||
| } // namespace din::asr::common |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| add_din_shared_library(din_asr_nemotron nemotron.cpp) | ||
| target_include_directories(din_asr_nemotron PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") | ||
| target_link_libraries(din_asr_nemotron PUBLIC din_asr_common din_common_ort din_common_io nlohmann_json::nlohmann_json) | ||
|
|
||
| add_din_executable(din_asr_nemotron_cli main.cpp) | ||
| target_link_libraries(din_asr_nemotron_cli PRIVATE din_asr_nemotron argparse) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Nemotron 3.5 ASR | ||
|
|
||
| NeMo → standard ONNX → C++ inference through ONNX Runtime (CPU or TensorRT RTX). | ||
|
|
||
| ## Export | ||
|
|
||
| Python 3.12+ is needed only for export and reference validation. | ||
|
|
||
| ```bash | ||
| python -m pip install -r asr/nemotron/requirements.txt | ||
| python asr/nemotron/model_export/export_nemotron.py --output artifacts/nemotron/onnx --device cpu --external-data | ||
| ``` | ||
|
|
||
| ## Build and run | ||
|
|
||
| ```bash | ||
| cmake --preset linux-x64 | ||
| cmake --build --preset linux-x64-release --target din_asr_nemotron_cli | ||
| out/build/linux-x64/bin/Release/din_asr_nemotron_cli audio.wav --model-dir artifacts/nemotron/onnx --provider cpu --lang-id en-US | ||
| ``` | ||
|
|
||
| Use `--json` for a JSON transcript, or `--timestamps token` for token timestamps. | ||
| The existing C++ target names and exported artifact formats are preserved. | ||
|
|
||
| ## Validate | ||
|
|
||
| Compare one real recording against NeMo; add `--truth transcript.txt` to measure WER | ||
| against a human transcript, and `--max-wer 0.1` to enforce a threshold. | ||
|
|
||
| ```bash | ||
| python asr/nemotron/model_export/validate_nemotron.py --audio audio.wav \ | ||
| --cli out/build/linux-x64/bin/Release/din_asr_nemotron_cli \ | ||
| --model-dir artifacts/nemotron/onnx --lang-id en-US | ||
| ``` | ||
|
|
||
| The Python inference package, native bindings, dataset evaluation, plotting, and | ||
| quantization tools have been removed. Run inference with the C++ CLI; prepare | ||
| models with the scripts above. Shared NeMo export and validation helpers live in | ||
| `common/model_export/`; shared C++ ASR utilities live in `asr/common/`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not silently discard requested timestamps.
When a caller uses
--json --timestamps token, this branch returns success but omits every token timestamp. Parakeet also loses itssegmentoutput in JSON mode. Include the requested timestamps in the JSON result, or reject unsupported combinations before transcription. (raw.githubusercontent.com)