Skip to content

Commit

Permalink
beartype for init
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Sep 9, 2024
1 parent 953a3b6 commit f562ce6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 13 additions & 2 deletions e2_tts_pytorch/e2_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from itertools import zip_longest
from collections import namedtuple
from typing import Literal, Callable
from beartype import beartype

import torch
from torch import nn, tensor, from_numpy
Expand Down Expand Up @@ -304,6 +305,7 @@ def forward(
# for use in both e2tts as well as duration module

class Transformer(Module):
@beartype
def __init__(
self,
*,
Expand Down Expand Up @@ -569,14 +571,18 @@ def forward(
# main classes

class DurationPredictor(Module):
@beartype
def __init__(
self,
transformer: dict | Transformer,
num_channels = None,
mel_spec_kwargs: dict = dict(),
char_embed_kwargs: dict = dict(),
text_num_embeds = None,
tokenizer: str | Callable[[list[str]], Int['b nt']] = 'char_utf8'
tokenizer: (
Literal['char_utf8', 'phoneme_en'] |
Callable[[list[str]], Int['b nt']]
) = 'char_utf8'
):
super().__init__()

Expand Down Expand Up @@ -689,6 +695,8 @@ def forward(
return F.mse_loss(pred, lens.float())

class E2TTS(Module):

@beartype
def __init__(
self,
transformer: dict | Transformer = None,
Expand All @@ -706,7 +714,10 @@ def __init__(
frac_lengths_mask: tuple[float, float] = (0.7, 1.),
concat_cond = False,
text_num_embeds = None,
tokenizer: str | Callable[[list[str]], Int['b nt']] = 'char_utf8'
tokenizer: (
Literal['char_utf8', 'phoneme_en'] |
Callable[[list[str]], Int['b nt']]
) = 'char_utf8'
):
super().__init__()

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "e2-tts-pytorch"
version = "0.9.3"
version = "0.9.4"
description = "E2-TTS in Pytorch"
authors = [
{ name = "Phil Wang", email = "lucidrains@gmail.com" }
Expand All @@ -25,6 +25,7 @@ classifiers=[

dependencies = [
'accelerate>=0.33.0',
'beartype',
'einops>=0.8.0',
'einx>=0.3.0',
'ema-pytorch>=0.5.2',
Expand Down

0 comments on commit f562ce6

Please sign in to comment.