Skip to content

[Bug] Native CLI can consume the local filename as a keyword and select the default sample #175

Description

@LauraGPT

Observed input-selection problem

On current main 0339018ba74a7defa3b6b6a96718d17b816be77b, the native Transformers CLI can select the bundled English sample instead of an explicitly supplied local recording when keyword options precede the filename:

python examples/transformers/transcribe.py --keywords OpenAI recording.wav

--keywords uses nargs="*", so argparse consumes both OpenAI and recording.wav as keywords. The positional audio list is empty, and main() enters its default example/en.mp3 download path. This can make a user evaluate the wrong input and trigger an unintended sample/model download. The README's file-first commands are unaffected.

Reproduction and controls

Using a valid, synthetic one-second mono 16 kHz WAV:

Arguments after the script Actual selected input boundary
recording.wav --keywords OpenAI Local WAV, decoded to 16000 samples
--keywords OpenAI recording.wav Default pinned example/en.mp3 downloader
--keywords OpenAI -- recording.wav Local WAV, decoded to 16000 samples
--prompt test recording.wav Local WAV, decoded to 16000 samples

The probe executed the current script's real main(), argparse and CPU runtime validation. It intercepted huggingface_hub.hf_hub_download to record its requested repository/file/revision and stop before downloading; the three controls executed the real local audio decoder and stopped before processor/model loading. Thus this verifies wrong input selection, not a completed wrong transcript. No model weights, network downloads, GPU or inference were used. Script SHA256: ba75c4bf8ee080650efc11e1403583c093882f5ad813e8e26be98923fac0e54a.

Immediate workaround

Put recordings before the variable-length options, as documented, or use -- to terminate options:

python examples/transformers/transcribe.py recording.wav --keywords OpenAI
python examples/transformers/transcribe.py --keywords OpenAI -- recording.wav

Proposed acceptance criteria

Prevent ambiguous keyword-only parsing from silently choosing the official sample. A clear usage error before any download is preferable to guessing which keyword is a filename. Preserve the ordinary no-argument sample demo and documented file-first multi-keyword/batch usage. Add CLI-level tests for the four input-selection cases above, including a downloader-not-called assertion for the rejected ambiguous case. The precise CLI compatibility policy still needs design approval; no implementation is included here.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions