saeki
commited on
Commit
•
a9849ea
1
Parent(s):
a3812f7
fix
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import numpy as np
|
|
6 |
from lightning_module import SSLDualLightningModule
|
7 |
import gradio as gr
|
8 |
import subprocess
|
|
|
9 |
|
10 |
def normalize_waveform(wav, sr, db=-3):
|
11 |
wav, _ = torchaudio.sox_effects.apply_effects_tensor(
|
@@ -15,6 +16,35 @@ def normalize_waveform(wav, sr, db=-3):
|
|
15 |
)
|
16 |
return wav.squeeze(0)
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
def calc_spectrogram(wav, config):
|
19 |
spec_module = torchaudio.transforms.MelSpectrogram(
|
20 |
sample_rate=config["preprocess"]["sampling_rate"],
|
@@ -74,6 +104,7 @@ def transfer(audio):
|
|
74 |
|
75 |
if __name__ == "__main__":
|
76 |
subprocess.run(["curl", "-OL", "https://sarulab.sakura.ne.jp/saeki/selfremaster/pretrained/tono_aet_melspec.ckpt"])
|
|
|
77 |
subprocess.run(["ls", "-a"])
|
78 |
subprocess.run(["ls", "-a", "aet_sample"])
|
79 |
|
|
|
6 |
from lightning_module import SSLDualLightningModule
|
7 |
import gradio as gr
|
8 |
import subprocess
|
9 |
+
import requests
|
10 |
|
11 |
def normalize_waveform(wav, sr, db=-3):
|
12 |
wav, _ = torchaudio.sox_effects.apply_effects_tensor(
|
|
|
16 |
)
|
17 |
return wav.squeeze(0)
|
18 |
|
19 |
+
def download_file_from_google_drive(id, destination):
|
20 |
+
URL = "https://docs.google.com/uc?export=download"
|
21 |
+
|
22 |
+
session = requests.Session()
|
23 |
+
|
24 |
+
response = session.get(URL, params = { 'id' : id }, stream = True)
|
25 |
+
token = get_confirm_token(response)
|
26 |
+
|
27 |
+
if token:
|
28 |
+
params = { 'id' : id, 'confirm' : token }
|
29 |
+
response = session.get(URL, params = params, stream = True)
|
30 |
+
|
31 |
+
save_response_content(response, destination)
|
32 |
+
|
33 |
+
def get_confirm_token(response):
|
34 |
+
for key, value in response.cookies.items():
|
35 |
+
if key.startswith('download_warning'):
|
36 |
+
return value
|
37 |
+
|
38 |
+
return None
|
39 |
+
|
40 |
+
def save_response_content(response, destination):
|
41 |
+
CHUNK_SIZE = 32768
|
42 |
+
|
43 |
+
with open(destination, "wb") as f:
|
44 |
+
for chunk in response.iter_content(CHUNK_SIZE):
|
45 |
+
if chunk: # filter out keep-alive new chunks
|
46 |
+
f.write(chunk)
|
47 |
+
|
48 |
def calc_spectrogram(wav, config):
|
49 |
spec_module = torchaudio.transforms.MelSpectrogram(
|
50 |
sample_rate=config["preprocess"]["sampling_rate"],
|
|
|
104 |
|
105 |
if __name__ == "__main__":
|
106 |
subprocess.run(["curl", "-OL", "https://sarulab.sakura.ne.jp/saeki/selfremaster/pretrained/tono_aet_melspec.ckpt"])
|
107 |
+
download_file_from_google_drive("10OJ2iznutxzp8MEIS6lBVaIS_g5c_70V", "hifigan/hifigan_melspec_universal")
|
108 |
subprocess.run(["ls", "-a"])
|
109 |
subprocess.run(["ls", "-a", "aet_sample"])
|
110 |
|