Spaces:
Runtime error
Runtime error
Fix scaling
Browse files- inference.py +4 -3
inference.py
CHANGED
|
@@ -47,7 +47,6 @@ class EnClap:
|
|
| 47 |
"pad_token_id": 1,
|
| 48 |
"max_length": 50,
|
| 49 |
}
|
| 50 |
-
self.scale_factor = 2**15
|
| 51 |
self.max_seq_len = config.max_position_embeddings - 3
|
| 52 |
|
| 53 |
@torch.no_grad()
|
|
@@ -65,8 +64,10 @@ class EnClap:
|
|
| 65 |
) -> str:
|
| 66 |
if generation_config is None:
|
| 67 |
generation_config = self.generation_config
|
| 68 |
-
if audio.dtype == torch.
|
| 69 |
-
audio = audio /
|
|
|
|
|
|
|
| 70 |
encodec_audio = (
|
| 71 |
convert_audio(
|
| 72 |
audio.unsqueeze(0), res, self.encodec.sample_rate, self.encodec.channels
|
|
|
|
| 47 |
"pad_token_id": 1,
|
| 48 |
"max_length": 50,
|
| 49 |
}
|
|
|
|
| 50 |
self.max_seq_len = config.max_position_embeddings - 3
|
| 51 |
|
| 52 |
@torch.no_grad()
|
|
|
|
| 64 |
) -> str:
|
| 65 |
if generation_config is None:
|
| 66 |
generation_config = self.generation_config
|
| 67 |
+
if audio.dtype == torch.short:
|
| 68 |
+
audio = audio / 2**15
|
| 69 |
+
if audio.dtype == torch.int:
|
| 70 |
+
audio = audio / 2**31
|
| 71 |
encodec_audio = (
|
| 72 |
convert_audio(
|
| 73 |
audio.unsqueeze(0), res, self.encodec.sample_rate, self.encodec.channels
|