fix: allow endpoint callers to select transcription language
The endpoint previously ignored language parameters, and its inference comment incorrectly said Mandarin was forced. This change lets callers select a transcription language for cross-language benchmarking.
- Accept
parameters.languagein JSON audio requests, such as"en"or"zh", and pass it to Whisper withtask="transcribe". - Preserve existing generation behavior when language is omitted or null. Copy the generation configuration to keep each language override local to its request.
- Correct the misleading comment, document request examples and defaults, and add six handler regression tests.
Example request:
{"inputs": "<base64-encoded audio>", "parameters": {"language": "en"}}
Validation: python -m unittest discover -s tests -v passed all 6 tests, covering request formats, defaults, malformed parameters, error propagation, and sequential request isolation. A separate local smoke test with a randomly initialized tiny Whisper model and this repository's generation configuration verified English code/name/token and Mandarin prompts, transcription task selection, invalid-language rejection, and unchanged shared configuration (Transformers 4.57.3, PyTorch 2.9.1 CPU). Diff whitespace checks passed. Uploaded files were verified against the tested local files.
Full model weights and the deployed endpoint were not exercised; these checks do not establish English transcription quality. After review and merge, redeploy the endpoint and smoke-test English, Mandarin, and an omitted-language request. Model weights, saved generation configuration, and dependencies are unchanged.
Thanks Greg! The changes look good, merging it now.