Skip to content

fix: initialize encoding variable before conditional in inference - #4402

Closed
Mr-Neutr0n wants to merge 1 commit into
coqui-ai:devfrom
Mr-Neutr0n:fix/encoding-uninitialized-inference
Closed

fix: initialize encoding variable before conditional in inference#4402
Mr-Neutr0n wants to merge 1 commit into
coqui-ai:devfrom
Mr-Neutr0n:fix/encoding-uninitialized-inference

Conversation

@Mr-Neutr0n

Copy link
Copy Markdown

Summary

  • In AcousticModel.inference(), the encoding variable was only assigned inside a conditional block (if encoder_outputs_ex.shape[1] > pos_encoding.shape[1]), meaning it would be undefined when the condition is False.
  • This causes a NameError at runtime when self.decoder() is called with encoding=encoding.
  • Fixed by defaulting encoding = pos_encoding before the conditional, so the variable is always initialized regardless of whether the expanded encoder output is longer than the original positional encoding.

Test plan

  • Verify inference() no longer raises NameError when encoder_outputs_ex.shape[1] <= pos_encoding.shape[1]
  • Confirm behavior is unchanged when the condition is True (encoding is still recomputed for the expanded length)

@CLAassistant

CLAassistant commented Feb 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Mr-Neutr0n

Copy link
Copy Markdown
Author

closing this out — saw the note about the repo being unmaintained. will redirect to the active fork if still relevant

@Mr-Neutr0n Mr-Neutr0n closed this Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants