Spaces:
Build error
Build error
File size: 1,007 Bytes
66dcbda 012976e 66dcbda c719a8e bd1f0fe 66dcbda 012976e c719a8e 012976e 3660947 012976e d07be14 012976e c5ee48a 012976e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import gradio
import numpy as np
import torch
from hifi_gan_bwe import BandwidthExtender
MAX_LENGTH = 30.0
model = BandwidthExtender.from_pretrained("hifi-gan-bwe-10-42890e3-vctk-48kHz")
def extend(audio):
fs, x = audio
x = x[:int(MAX_LENGTH * fs)]
x = x.astype(np.float32) / 32767.0
if len(x.shape) == 1:
x = x[:, np.newaxis]
with torch.no_grad():
y = np.stack([model(torch.from_numpy(x), fs) for x in x.T]).T
y = (y * 32767.0).astype(np.int16)
fs = int(model.sample_rate)
return fs, y
gradio.Interface(
fn=extend,
examples=[["examples/example.wav"]],
title="HiFi-GAN+",
description="""
An audio bandwidth extension model from the paper
[Bandwidth Extension is All You Need](https://doi.org/10.1109/ICASSP39728.2021.9413575)
by Su, et al.
For more information, see this
[blog post](https://brentspell.com/2022/hifi-gan-bwe).
""",
thumbnail="https://brentspell.com/favicon-32x32.png",
inputs="audio",
outputs="audio",
).launch()
|