tiny-voca-da / recipe /scripts /train_texture_low.py
inlanger's picture
tiny-voca-da v0.1: frontend v4 + sm9 vocoder (ONNX fp32/int8, PyTorch, frontend, recipe, samples)
adabee1 verified
Raw History Blame Contribute Delete
1.13 kB
"""tiny_voca.train with the texture loss starting at TEXTURE_LOW_HZ instead of the built-in 2 kHz.
The texture loss (``--texture W``) matches the amount of frame-to-frame change of the Vocos log-mel
per band and utterance. Upstream hard-codes its bands to centres >= 2 kHz
(TrainingSystem.texture_bands, low_hz=2000). Night of 2026-11-25: with it, vowel motion reached
-3% / -6% of the real speaker at 2-4 / 4-8 kHz, but 1-2 kHz stayed 10% short. This wrapper moves
the start of the band without rebuilding the image. All arguments go to tiny_voca.train unchanged:
TEXTURE_LOW_HZ=1000 python scripts/train_texture_low.py --texture 20 ...
"""
import os
import sys
from tiny_voca import train
LOW_HZ = float(os.environ.get('TEXTURE_LOW_HZ', '2000'))
_original = train.TrainingSystem.texture_bands.__func__
def _texture_bands(cls, bands, device, low_hz=2000.0):
return _original(cls, bands, device, LOW_HZ)
train.TrainingSystem.texture_bands = classmethod(_texture_bands)
if __name__ == '__main__':
print(f'texture loss bands from {LOW_HZ:.0f} Hz', flush=True)
sys.argv[0] = 'tiny_voca.train'
train.main()