Skip to content

fix(kws): keep transcript words that match the utterance id - #3979

Open
nurlanmnn wants to merge 2 commits into
modelscope:mainfrom
nurlanmnn-open-source:fix-kws-trans-key-strip
Open

nurlanmnn wants to merge 2 commits into
modelscope:mainfrom
nurlanmnn-open-source:fix-kws-trans-key-strip

Conversation

@nurlanmnn

Copy link
Copy Markdown
Contributor

Summary

Fixes #3978

make_pair() in funasr/utils/compute_det_ctc.py took the transcript with line.replace(arr[0], ''), which removes the utterance id everywhere in the line. When the id also shows up in the transcript (1 turn on light 1, go go go forward), those words were lost. Now it takes everything after the first field instead.

Type of change

  • Bug fix
  • Documentation
  • Example or demo
  • Runtime or deployment
  • Benchmark or evaluation
  • Model/training change

Validation

  • python -m pytest tests/test_compute_det_ctc_make_pair.py -q: 6 passed. It covers ids that appear in the transcript, an id that is a prefix of a word, extra spaces and tabs, and the skipped/unmatched lines. 4 cases fail on main and all pass with the fix.
  • python -m compileall on the changed file is clean.
  • Docs or links checked
  • Runtime/deployment command tested

User impact

KWS scoring with compute_det_ctc.py now uses the full transcript, so utterances whose id matches a word in the text are classed correctly as keyword or filler.

Notes for reviewers

One-line change. Spacing inside the transcript is kept as before. The test loads make_pair from the file so it runs without the audio dependencies.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LauraGPT

LauraGPT commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

I verified the scoring fix on this head. In an offline run of the actual DET CLI with a generated WAV and synthetic keyword scores, the old code exited 0 but omitted the expected keyword statistics; your change preserved the repeated ID and produced the expected statistics. This validates the evaluator, not recognition accuracy.

The remaining integration gap is hosted coverage: no Actions suite is attached to this revision. Could you include the following small change on this PR? It selects the scorer and its tests on pull requests and main, checks out the exact PR head and runs the six new cases alongside the existing KWS suite. I applied this diff to 722e5e1ac5fa and ran that selection offline: 108 passed with local temporary storage. An initial CPFS-only temporary-directory cleanup error in a streaming test is not a scoring failure. This is local validation, not a hosted CI result.

Tested workflow diff
--- a/.github/workflows/test-kws-output.yml
+++ b/.github/workflows/test-kws-output.yml
@@ -12,6 +12,8 @@
       - "funasr/auto/auto_model.py"
       - "funasr/utils/datadir_writer.py"
       - "funasr/utils/kws_utils.py"
+      - "funasr/utils/compute_det_ctc.py"
+      - "tests/test_compute_det_ctc_make_pair.py"
       - "tests/test_kws_optional_output.py"
       - "tests/test_kws_streaming_continuity.py"
       - "tests/test_kws_utils.py"
@@ -32,6 +34,8 @@
       - "funasr/auto/auto_model.py"
       - "funasr/utils/datadir_writer.py"
       - "funasr/utils/kws_utils.py"
+      - "funasr/utils/compute_det_ctc.py"
+      - "tests/test_compute_det_ctc_make_pair.py"
       - "tests/test_kws_optional_output.py"
       - "tests/test_kws_streaming_continuity.py"
       - "tests/test_kws_utils.py"
@@ -53,6 +57,8 @@
       MKL_NUM_THREADS: "1"
     steps:
       - uses: actions/checkout@v4
+        with:
+          ref: ${{ github.event.pull_request.head.sha || github.sha }}
       - uses: actions/setup-python@v5
         with:
           python-version: "3.11"
@@ -67,6 +73,7 @@
             tests/test_kws_optional_output.py \
             tests/test_kws_streaming_continuity.py \
             tests/test_kws_utils.py \
+            tests/test_compute_det_ctc_make_pair.py \
             tests/test_wav_frontend_no_lfr.py \
             tests/test_fsmn_vad_streaming_buffers.py \
             tests/test_dynamic_streaming_vad.py \

Trigger the KWS output workflow on changes to compute_det_ctc.py and its
tests, check out the exact PR head, and add
tests/test_compute_det_ctc_make_pair.py to the pytest selection, as
suggested in review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@nurlanmnn

Copy link
Copy Markdown
Contributor Author

@LauraGPT Added your workflow change in e348f42: the KWS workflow now triggers on funasr/utils/compute_det_ctc.py and its test, checks out the exact PR head, and runs tests/test_compute_det_ctc_make_pair.py with the KWS suite. Locally I only ran the new test file (6 passed), not the full selection.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compute_det_ctc make_pair drops transcript words that equal the utterance id

2 participants