Spaces:
Running
on
Zero
Running
on
Zero
Harry Coultas Blum
commited on
Commit
·
c64babc
1
Parent(s):
8b2e529
trying to cast
Browse files- vui/inference.py +4 -1
vui/inference.py
CHANGED
@@ -5,6 +5,7 @@ import inflect
|
|
5 |
import torch
|
6 |
import torch.nn.functional as F
|
7 |
import torchaudio
|
|
|
8 |
from torch import Tensor
|
9 |
from torch.nn.attention import SDPBackend, sdpa_kernel
|
10 |
|
@@ -12,6 +13,7 @@ from vui.model import Vui
|
|
12 |
from vui.sampling import multinomial, sample_top_k, sample_top_p, sample_top_p_top_k
|
13 |
from vui.vad import detect_voice_activity as vad
|
14 |
|
|
|
15 |
|
16 |
def ensure_spaces_around_tags(text: str):
|
17 |
# Add space before '[' if not preceded by space, '<', or '['
|
@@ -328,7 +330,8 @@ def render(
|
|
328 |
)
|
329 |
codes = codes[..., :-10]
|
330 |
audio = self.codec.from_indices(codes)
|
331 |
-
|
|
|
332 |
results = vad(paudio)
|
333 |
|
334 |
if len(results):
|
|
|
5 |
import torch
|
6 |
import torch.nn.functional as F
|
7 |
import torchaudio
|
8 |
+
from torchaudio.transforms import Resample
|
9 |
from torch import Tensor
|
10 |
from torch.nn.attention import SDPBackend, sdpa_kernel
|
11 |
|
|
|
13 |
from vui.sampling import multinomial, sample_top_k, sample_top_p, sample_top_p_top_k
|
14 |
from vui.vad import detect_voice_activity as vad
|
15 |
|
16 |
+
resample = Resample(22050, 16000).cuda()
|
17 |
|
18 |
def ensure_spaces_around_tags(text: str):
|
19 |
# Add space before '[' if not preceded by space, '<', or '['
|
|
|
330 |
)
|
331 |
codes = codes[..., :-10]
|
332 |
audio = self.codec.from_indices(codes)
|
333 |
+
|
334 |
+
paudio = resample(audio[0])
|
335 |
results = vad(paudio)
|
336 |
|
337 |
if len(results):
|