Skip to content

fix(cli): give single-row TSV output the real time span - #3750

Closed
Arthur031221 wants to merge 1 commit into
modelscope:mainfrom
Arthur031221:fix/cli-tsv-fallback-span
Closed

Arthur031221 wants to merge 1 commit into
modelscope:mainfrom
Arthur031221:fix/cli-tsv-fallback-span

Conversation

@Arthur031221

Copy link
Copy Markdown
Contributor

Summary

funasr FILE -f tsv writes 0.000 as both start and end of its only row when the result has no sentence-level timestamps (an empty or missing sentence_info). -f srt already handles that case by spanning the token timestamps, or the audio length if there are none. This change moves that span logic into one helper, _fallback_bounds_ms, and uses it for both formats. SRT output is unchanged.

Type of change

  • Bug fix

Validation

  • python -m compileall funasr/cli.py tests/test_cli.py: passes.
  • pytest tests/test_cli.py: 29 passed. With funasr/cli.py restored to the base commit, the new TSV test fails (0.000 0.000 hello world instead of 0.300 1.700 hello world) and the other 28 pass.
  • The new SRT test passes on both base and branch; it pins the unchanged SRT behaviour.
  • The tests use a stub AutoModel returning sentence_info: [] and token timestamps [[300, 800], [900, 1700]]. I did not run a real model.

User impact

Anyone running funasr audio.wav -m fun-asr-nano -f tsv got the whole transcript on one row timed 0.000 to 0.000. The fun-asr-nano entry in MODEL_CONFIGS has no punctuation model and the CLI does not add one for it, so with token timestamps present inference_with_vad sets sentence_info to [] (the "punc_model is required for sentence_timestamp" warning branch). I confirmed that branch by reading auto_model.py and by driving inference_with_vad with stubs, not with the real model.

Notes for reviewers

  • The fix is in the CLI formatter, matching how the SRT fallback already handles this case. It does not add per-sentence TSV rows for such models: the output is still one row, now spanning the first to the last token timestamp.
  • When there are neither sentence segments nor usable token timestamps (including an empty transcript), the row spans 0 to the audio duration, or 0 to 0 if the duration cannot be read. SRT already does the same.

When a result has no sentence_info, -f tsv wrote 0.000 as both start and
end, while -f srt already spans the token timestamps or the audio length.
Share that span between the two formats.

@LauraGPT LauraGPT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed e3a2821d489f5aa646139dfafd3b8ff415ce1cfb against its parent 4a84879ae8ca4d2430953b11c49d609217d93988. No actionable correctness findings in this change.

Independent CPU validation using the same complete tests/test_cli.py from this PR:

  • Parent: 28 passed, 1 failed. The new TSV regression reproduces the incorrect 0.000 -> 0.000 bounds.
  • PR head: 29 passed, 0 skipped/errors.
  • Additional 14 boundary cases (26 assertions) passed: token bounds, dictionary/unsorted timestamps, actual WAV-duration fallback, unreadable audio, empty/unusable timestamps, unchanged sentence-segment output, and byte-equivalent SRT output.

The shared fallback preserves the existing SRT behavior while giving the single TSV row the available time span. Validation used model doubles at the existing test boundary; no real-model inference or full-repository test claim.

Commit metadata note: this head is unsigned and has no Signed-off-by trailer. This is a comment-only technical review, not a merge-policy approval.

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.

2 participants