Conversation
LiveReview Pre-Commit Check: ran (iter:5, coverage:96%)
…date tests and e2e tests LiveReview Pre-Commit Check: ran (iter:4, coverage:98%)
LiveReview Pre-Commit Check: ran (iter:1, coverage:0%)
PR Summary by QodoRefactor: Replace openWakeWord with direct ONNX Runtime wake word detection Description
Diagram
High-Level Assessment
Files changed (13)
|
Code Review by Qodo
1. Hardcoded ONNX input names
|
| outputs = cast("list[NDArray[np.float32]]", self.melspec_session.run(None, {'input': arr})) # pyright: ignore[reportUnknownMemberType] | ||
| spec = outputs[0] | ||
|
|
||
| if spec.ndim == 4: | ||
| spec = np.squeeze(spec, axis=(0, 1)) | ||
|
|
||
| spec = melspec_transform(spec) | ||
| return spec | ||
|
|
||
| def _get_embeddings_from_melspec(self, melspec: NDArray[np.float32]) -> NDArray[np.float32]: | ||
| """Compute the Google speech embedding features from a mel-spectrogram.""" | ||
| if melspec.ndim == 2: | ||
| melspec = np.expand_dims(melspec, axis=0) | ||
| if melspec.ndim == 3: | ||
| melspec = np.expand_dims(melspec, axis=-1) | ||
|
|
||
| res = cast("list[NDArray[np.float32]]", self.embedding_session.run(None, {'input_1': melspec}))[0] # pyright: ignore[reportUnknownMemberType] | ||
| return np.reshape(res, (melspec.shape[0], 96)) |
There was a problem hiding this comment.
1. Hardcoded onnx input names 🐞 Bug ≡ Correctness
ONNXAudioFeatures calls ONNX Runtime with fixed input keys ('input' and 'input_1') instead of using
the model-declared input names, so inference can fail at runtime if the shipped ONNX models use
different tensor names. This would break feature extraction and prevent wake-word detection from
working.
Agent Prompt
### Issue description
`ONNXAudioFeatures` hardcodes ONNX input tensor names when calling `InferenceSession.run()`, which is brittle: ONNX exported graphs frequently use different input names.
### Issue Context
`WakeWordDetector` already queries the wake-word model input name dynamically (`get_inputs()[0].name`), but the melspectrogram and embedding sessions do not.
### Fix Focus Areas
- src/audio/wake_word.py[106-140]
### Suggested fix
- In `ONNXAudioFeatures.__init__`, store the actual input names:
- `self._melspec_input_name = melspec_session.get_inputs()[0].name`
- `self._embedding_input_name = embedding_session.get_inputs()[0].name`
- Use those names in `.run()` calls instead of `'input'` / `'input_1'`.
- Optionally validate expected input shapes at load time and raise a clear error if incompatible.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
No description provided.