Files
chaojie-ComfyUI_StreamingT2V/thirdparty/modelscope/models/audio/ans/layers/layer_base.py
T
2024-04-08 06:24:30 +08:00

33 lines
753 B
Python

# These codes are copied from modelscope revision c58451baead80d83281f063d12fb377fad415257
# Copyright (c) Alibaba, Inc. and its affiliates.
import abc
import numpy as np
import six
import torch.nn as nn
def to_kaldi_matrix(np_mat):
""" function that transform as str numpy mat to standard kaldi str matrix
Args:
np_mat: numpy mat
"""
np.set_printoptions(threshold=np.inf, linewidth=np.nan)
out_str = str(np_mat)
out_str = out_str.replace('[', '')
out_str = out_str.replace(']', '')
return '[ %s ]\n' % out_str
@six.add_metaclass(abc.ABCMeta)
class LayerBase(nn.Module):
def __init__(self):
super(LayerBase, self).__init__()
@abc.abstractmethod
def to_kaldi_nnet(self):
pass