Copy the files in the new repo for public release

This commit is contained in:
gabrieldemarmiesse
2026-01-12 11:25:16 +01:00
commit f5fa328a58
54 changed files with 6411 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import torch
from torch import nn
from pocket_tts.modules.conv import StreamingConv1d, StreamingConvTranspose1d
class ConvDownsample1d(nn.Module):
"""
Downsampling by some integer amount `stride` using convolutions
with a kernel size of twice the stride.
"""
def __init__(self, stride: int, dimension: int):
super().__init__()
self.conv = StreamingConv1d(
dimension,
dimension,
kernel_size=2 * stride,
stride=stride,
groups=1,
bias=False,
pad_mode="replicate",
)
def forward(self, x: torch.Tensor, model_state: dict | None):
return self.conv(x, model_state)
class ConvTrUpsample1d(nn.Module):
"""
Upsample by some integer amount `stride` using transposed convolutions.
"""
def __init__(self, stride: int, dimension: int):
super().__init__()
self.convtr = StreamingConvTranspose1d(
dimension,
dimension,
kernel_size=2 * stride,
stride=stride,
groups=dimension,
bias=False,
)
def forward(self, x: torch.Tensor, model_state: dict | None):
return self.convtr(x, model_state)