drop initial_prompt (rejected by transformers 4.46 generate kwargs)
Browse files- kaggle/ming_eval.py +4 -3
kaggle/ming_eval.py
CHANGED
|
@@ -174,12 +174,13 @@ def build_asr():
|
|
| 174 |
pipe = pipeline("automatic-speech-recognition", torch_dtype=torch.float16, **kwargs)
|
| 175 |
except Exception:
|
| 176 |
pipe = pipeline("automatic-speech-recognition", **kwargs)
|
| 177 |
-
prompt = "以下是普通话的句子,请使用简体中文转写。" # pushes Whisper off traditional output
|
| 178 |
-
|
| 179 |
def asr(wav: np.ndarray, sr: int = 44100) -> str:
|
|
|
|
|
|
|
|
|
|
| 180 |
out = pipe(
|
| 181 |
{"array": wav.astype(np.float32), "sampling_rate": sr},
|
| 182 |
-
generate_kwargs={"language": "zh", "task": "transcribe"
|
| 183 |
)
|
| 184 |
return out.get("text", "") if isinstance(out, dict) else str(out)
|
| 185 |
|
|
|
|
| 174 |
pipe = pipeline("automatic-speech-recognition", torch_dtype=torch.float16, **kwargs)
|
| 175 |
except Exception:
|
| 176 |
pipe = pipeline("automatic-speech-recognition", **kwargs)
|
|
|
|
|
|
|
| 177 |
def asr(wav: np.ndarray, sr: int = 44100) -> str:
|
| 178 |
+
# No initial_prompt here: transformers 4.46 rejects it as a generate
|
| 179 |
+
# kwarg. Whisper's traditional-character output is handled downstream
|
| 180 |
+
# by eval/score.py, which normalises before counting edits.
|
| 181 |
out = pipe(
|
| 182 |
{"array": wav.astype(np.float32), "sampling_rate": sr},
|
| 183 |
+
generate_kwargs={"language": "zh", "task": "transcribe"},
|
| 184 |
)
|
| 185 |
return out.get("text", "") if isinstance(out, dict) else str(out)
|
| 186 |
|