(
self,
phonemes: str,
ref_s: torch.FloatTensor,
speed: float = 1,
return_output: bool = False
)
| 123 | return audio, pred_dur |
| 124 | |
| 125 | def forward( |
| 126 | self, |
| 127 | phonemes: str, |
| 128 | ref_s: torch.FloatTensor, |
| 129 | speed: float = 1, |
| 130 | return_output: bool = False |
| 131 | ) -> Union['KModel.Output', torch.FloatTensor]: |
| 132 | input_ids = list(filter(lambda i: i is not None, map(lambda p: self.vocab.get(p), phonemes))) |
| 133 | logger.debug(f"phonemes: {phonemes} -> input_ids: {input_ids}") |
| 134 | assert len(input_ids)+2 <= self.context_length, (len(input_ids)+2, self.context_length) |
| 135 | input_ids = torch.LongTensor([[0, *input_ids, 0]]).to(self.device) |
| 136 | ref_s = ref_s.to(self.device) |
| 137 | audio, pred_dur = self.forward_with_tokens(input_ids, ref_s, speed) |
| 138 | audio = audio.squeeze().cpu() |
| 139 | pred_dur = pred_dur.cpu() if pred_dur is not None else None |
| 140 | logger.debug(f"pred_dur: {pred_dur}") |
| 141 | return self.Output(audio=audio, pred_dur=pred_dur) if return_output else audio |
| 142 | |
| 143 | class KModelForONNX(torch.nn.Module): |
| 144 | def __init__(self, kmodel: KModel): |
nothing calls this directly
no test coverage detected