This kind of 1/32nd stuff makes me nervous.  Also, this means that profanity gets emitted with a frequency of 1, leaving only the 30 values 2 to 31 for other words. We're not using the value 0 here in the binary format.

Can we just modify emitNode at line 397 instead?

instead of freq = int(node.frequency * 32) do something like

if (node.frequency === 0)
  freq = 0;
else 
  freq = 1 + int(node.frequency * 31)

That's probably not valid python syntax, but doing the fix here seems cleaner to me.  Then you'll need to modify the code on the javascript side to add one to the frequency after reading it.  I'm assuming that python's int() does truncation or Math.floor(), rather than rounding to the nearest.