MCPcopy Create free account
hub / github.com/FireRedTeam/FireRedTTS2 / RedCodec

Class RedCodec

fireredtts2/codec/model.py:151–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149
150
151class RedCodec(nn.Module):
152 def __init__(
153 self,
154 ssl: PretrainedWhisperEncoder,
155 ssl_adaptor: SslAdaptor,
156 acoustic_encoder: WhisperAcousticEncoder,
157 downsample: ResidualDownConv,
158 rvq: ResidualVQ,
159 upsample: UpConv,
160 semantic_decoder: SslAdaptor,
161 acoustic_decoder: AcousticDecoder,
162 ):
163 super().__init__()
164 self.ssl = ssl
165 self.ssl_adaptor = ssl_adaptor
166 self.acoustic_encoder = acoustic_encoder
167 self.downsample = downsample
168 self.rvq = rvq
169 self.upsample = upsample
170 self.semantic_decoder = semantic_decoder
171 self.acoustic_decoder = acoustic_decoder
172
173 @classmethod
174 def from_config(cls, config_json: str) -> "RedCodec":
175 with open(config_json, "rb") as f:
176 config = json.load(f)["codec"]
177 ssl = PretrainedWhisperEncoder.from_pretrained()
178 ssl_adaptor = SslAdaptor(**config["ssl_adaptor"])
179 acoustic_encoder = WhisperAcousticEncoder(**config["acoustic_encoder"])
180 downsample = ResidualDownConv(**config["downsample"])
181 rvq = ResidualVQ(**config["rvq"])
182 upsample = UpConv(**config["upsample"])
183 semantic_decoder = SslAdaptor(**config["semantic_decoder"])
184 acoustic_decoder = AcousticDecoder(**config["acoustic_decoder"])
185 return cls(
186 ssl,
187 ssl_adaptor,
188 acoustic_encoder,
189 downsample,
190 rvq,
191 upsample,
192 semantic_decoder,
193 acoustic_decoder,
194 )
195
196
197class RedCodecInfer(RedCodec):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected