WakewordModel: print shapes at startup + tidy mel-shape comment
Add PrintShapes() helper that writes input/output name, shape, and dtype for each InferenceSession to stderr at construction time, prefixed with [wakeword-model]. Called after each of the three session creations so the geometry is visible on first run without grep-ing logs. Also rephrase the stale "FIXED:" comment on the mel Dimensions[2] indexing to plain explanatory text that describes the current invariant.
This commit is contained in:
@@ -59,8 +59,11 @@ internal sealed class WakewordModel : IDisposable
|
||||
};
|
||||
|
||||
_mel = new InferenceSession(melPath, opts);
|
||||
PrintShapes(Path.GetFileName(melPath), _mel);
|
||||
_emb = new InferenceSession(embeddingPath, opts);
|
||||
PrintShapes(Path.GetFileName(embeddingPath), _emb);
|
||||
_cls = new InferenceSession(classifierPath, opts);
|
||||
PrintShapes(Path.GetFileName(classifierPath), _cls);
|
||||
|
||||
// Discover input names + assert shape geometry.
|
||||
_melInputName = _mel.InputMetadata.Keys.Single();
|
||||
@@ -70,6 +73,17 @@ internal sealed class WakewordModel : IDisposable
|
||||
AssertClassifierShape(_cls); // [batch, 16, 96], dtype float
|
||||
}
|
||||
|
||||
private static void PrintShapes(string filename, InferenceSession sess)
|
||||
{
|
||||
Console.Error.WriteLine($"[wakeword-model] {filename}");
|
||||
foreach (var kv in sess.InputMetadata)
|
||||
Console.Error.WriteLine(
|
||||
$" input '{kv.Key}': shape=[{string.Join(",", kv.Value.Dimensions)}] dtype={kv.Value.ElementType.Name}");
|
||||
foreach (var kv in sess.OutputMetadata)
|
||||
Console.Error.WriteLine(
|
||||
$" output '{kv.Key}': shape=[{string.Join(",", kv.Value.Dimensions)}] dtype={kv.Value.ElementType.Name}");
|
||||
}
|
||||
|
||||
private static void AssertEmbeddingShape(InferenceSession sess)
|
||||
{
|
||||
if (!sess.InputMetadata.TryGetValue(EmbeddingInputName, out var meta))
|
||||
@@ -144,7 +158,7 @@ internal sealed class WakewordModel : IDisposable
|
||||
var melOut = melResults.First().AsTensor<float>(); // shape (1, 1, n_frames, 32)
|
||||
|
||||
// Apply openwakeword's `x / 10 + 2` transform and append each new frame to _melRing.
|
||||
// FIXED: actual mel output shape is (1, 1, n_frames, 32) — n_frames is at Dimensions[2], NOT [1].
|
||||
// Mel output shape is (1, 1, n_frames, 32). Note n_frames is at Dimensions[2], not [1].
|
||||
int nFrames = melOut.Dimensions[2];
|
||||
for (int f = 0; f < nFrames; f++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user