Add safetensors format + api.py safetensors support
Browse files- api.py +6 -1
- model.safetensors +3 -0
- model_fp16.safetensors +3 -0
api.py
CHANGED
|
@@ -46,7 +46,12 @@ class StableTTSAPI(nn.Module):
|
|
| 46 |
|
| 47 |
# text to mel spectrogram
|
| 48 |
self.tts_model = StableTTS(len(symbols), self.mel_config.n_mels, **asdict(self.tts_model_config))
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
self.tts_model.eval()
|
| 51 |
|
| 52 |
# mel spectrogram to waveform
|
|
|
|
| 46 |
|
| 47 |
# text to mel spectrogram
|
| 48 |
self.tts_model = StableTTS(len(symbols), self.mel_config.n_mels, **asdict(self.tts_model_config))
|
| 49 |
+
if tts_model_path.endswith(".safetensors"):
|
| 50 |
+
from safetensors.torch import load_file
|
| 51 |
+
state = load_file(tts_model_path)
|
| 52 |
+
else:
|
| 53 |
+
state = torch.load(tts_model_path, map_location='cpu', weights_only=True)
|
| 54 |
+
self.tts_model.load_state_dict(state)
|
| 55 |
self.tts_model.eval()
|
| 56 |
|
| 57 |
# mel spectrogram to waveform
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:171e6b9e2d610d0b0e23c7875d46303f120b53283d85f337bb513fdc09229e65
|
| 3 |
+
size 126289140
|
model_fp16.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c9023f08070131eecdbd4dee8ac98de2ecb1a9bc2548293a0ae19dd6ffaad035
|
| 3 |
+
size 63155050
|