Spaces:
Sleeping
Sleeping
Update hifigan/inference_e2e.py
Browse files- hifigan/inference_e2e.py +25 -1
hifigan/inference_e2e.py
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def hifi_gan_inference(input_mel, checkpoint_file):
|
| 2 |
print('Initializing Inference Process..')
|
| 3 |
config_file = os.path.join(os.path.split(checkpoint_file)[0], 'config.json')
|
|
@@ -49,4 +72,5 @@ def hifi_gan_inference(input_mel, checkpoint_file):
|
|
| 49 |
output_buffer = BytesIO()
|
| 50 |
write(output_buffer, h.sampling_rate, audio)
|
| 51 |
|
| 52 |
-
return output_buffer.getvalue()
|
|
|
|
|
|
| 1 |
+
from __future__ import absolute_import, division, print_function, unicode_literals
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import numpy as np
|
| 5 |
+
import json
|
| 6 |
+
import torch
|
| 7 |
+
from scipy.io.wavfile import write
|
| 8 |
+
from hifigan.env import AttrDict
|
| 9 |
+
from hifigan.models import Generator
|
| 10 |
+
from io import BytesIO
|
| 11 |
+
|
| 12 |
+
h = None
|
| 13 |
+
device = None
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def load_checkpoint(filepath, device):
|
| 17 |
+
assert os.path.isfile(filepath)
|
| 18 |
+
print("Loading '{}'".format(filepath))
|
| 19 |
+
checkpoint_dict = torch.load(filepath, map_location=device)
|
| 20 |
+
print("Complete.")
|
| 21 |
+
return checkpoint_dict
|
| 22 |
+
|
| 23 |
+
|
| 24 |
def hifi_gan_inference(input_mel, checkpoint_file):
|
| 25 |
print('Initializing Inference Process..')
|
| 26 |
config_file = os.path.join(os.path.split(checkpoint_file)[0], 'config.json')
|
|
|
|
| 72 |
output_buffer = BytesIO()
|
| 73 |
write(output_buffer, h.sampling_rate, audio)
|
| 74 |
|
| 75 |
+
return output_buffer.getvalue()
|
| 76 |
+
|