Hi @JoaoPigozzo
To enable word_timestamps=True when querying your Whisper model deployed as a serving endpoint in Databricks,
you must modify the serving endpointโs inference logic to accept and process this parameter.
1. Update your model serving function to accept word_timestamps
Inside the model serving code you deployed (likely a Python function or MLflow model),
update the handler to read from the input payload:
def predict(model_input):
import whisper
import base64
import io
audio_data = base64.b64decode(model_input["audio"])
audio = whisper.load_audio(io.BytesIO(audio_data))
word_ts = model_input.get("word_timestamps", False)
model = whisper.load_model("small")
result = model.transcribe(audio=audio, word_timestamps=word_ts)
return result
Make sure the model is set up as a custom Python function model or MLflow pyfunc with
this logic in the predict() or model.predict() function.
2. Pass the parameter in your Databricks query:
response = workspace_client.serving_endpoints.query(
name="whisperv3",
inputs={
"audio": base64_audio_chunks[first_audio_key],
"word_timestamps": True
}
)
print(response.predictions[0])
Notes:
If you are using MLflow to deploy, your model must include this in the predict() method in your PythonModel wrapper.
If using a Databricks Model Serving endpoint via custom serving handler (e.g., Model Serving with a REST API),
your server must interpret the incoming JSON and apply word_timestamps=True to the call to Whisper.
LR