Spaces:
Running
Running
admin
commited on
Commit
Β·
179dfee
1
Parent(s):
a2209d5
upd lang env
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import argparse
|
|
5 |
import warnings
|
6 |
import gradio as gr
|
7 |
from generate import generate_music, get_args
|
8 |
-
from utils import WEIGHTS_DIR, TEMP_DIR,
|
9 |
|
10 |
EN2ZH = {
|
11 |
"Cite": "εΌη¨",
|
@@ -43,7 +43,7 @@ EN2ZH = {
|
|
43 |
|
44 |
|
45 |
def _L(en_txt: str):
|
46 |
-
return en_txt if
|
47 |
|
48 |
|
49 |
def infer_by_template(dataset: str, v: str, a: str, add_chord: bool):
|
@@ -190,14 +190,14 @@ def save_template(label: str, pitch_std: str, mode: str, tempo: int, octave: int
|
|
190 |
if __name__ == "__main__":
|
191 |
warnings.filterwarnings("ignore")
|
192 |
with gr.Blocks() as demo:
|
193 |
-
if
|
194 |
gr.Markdown(
|
195 |
"## The current CPU-based version on HuggingFace has slow inference, you can access the GPU-based mirror on [ModelScope](https://www.modelscope.cn/studios/monetjoe/EMelodyGen)"
|
196 |
)
|
197 |
with gr.Row():
|
198 |
with gr.Column():
|
199 |
gr.Video(
|
200 |
-
"./demo.mp4" if
|
201 |
label=_L("Video demo"),
|
202 |
show_download_button=False,
|
203 |
show_share_button=False,
|
|
|
5 |
import warnings
|
6 |
import gradio as gr
|
7 |
from generate import generate_music, get_args
|
8 |
+
from utils import WEIGHTS_DIR, TEMP_DIR, EN_US
|
9 |
|
10 |
EN2ZH = {
|
11 |
"Cite": "εΌη¨",
|
|
|
43 |
|
44 |
|
45 |
def _L(en_txt: str):
|
46 |
+
return en_txt if EN_US else f"{en_txt} ({EN2ZH[en_txt]})"
|
47 |
|
48 |
|
49 |
def infer_by_template(dataset: str, v: str, a: str, add_chord: bool):
|
|
|
190 |
if __name__ == "__main__":
|
191 |
warnings.filterwarnings("ignore")
|
192 |
with gr.Blocks() as demo:
|
193 |
+
if EN_US:
|
194 |
gr.Markdown(
|
195 |
"## The current CPU-based version on HuggingFace has slow inference, you can access the GPU-based mirror on [ModelScope](https://www.modelscope.cn/studios/monetjoe/EMelodyGen)"
|
196 |
)
|
197 |
with gr.Row():
|
198 |
with gr.Column():
|
199 |
gr.Video(
|
200 |
+
"./demo.mp4" if EN_US else "./src/tutorial.mp4",
|
201 |
label=_L("Video demo"),
|
202 |
show_download_button=False,
|
203 |
show_share_button=False,
|
utils.py
CHANGED
@@ -9,10 +9,10 @@ import huggingface_hub
|
|
9 |
from tqdm import tqdm
|
10 |
|
11 |
TEMP_DIR = "./__pycache__"
|
12 |
-
|
13 |
WEIGHTS_DIR = (
|
14 |
huggingface_hub.snapshot_download("monetjoe/EMelodyGen", cache_dir=TEMP_DIR)
|
15 |
-
if
|
16 |
else modelscope.snapshot_download("monetjoe/EMelodyGen", cache_dir=TEMP_DIR)
|
17 |
)
|
18 |
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
9 |
from tqdm import tqdm
|
10 |
|
11 |
TEMP_DIR = "./__pycache__"
|
12 |
+
EN_US = os.getenv("LANG") != "zh_CN.UTF-8"
|
13 |
WEIGHTS_DIR = (
|
14 |
huggingface_hub.snapshot_download("monetjoe/EMelodyGen", cache_dir=TEMP_DIR)
|
15 |
+
if EN_US
|
16 |
else modelscope.snapshot_download("monetjoe/EMelodyGen", cache_dir=TEMP_DIR)
|
17 |
)
|
18 |
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|