Spaces:
Running
Running
audio base64
Browse files
app.py
CHANGED
@@ -1,14 +1,13 @@
|
|
1 |
import argparse
|
2 |
import glob
|
3 |
-
import os
|
4 |
import os.path
|
5 |
-
|
6 |
-
import
|
|
|
7 |
import gradio as gr
|
|
|
8 |
import numpy as np
|
9 |
import onnxruntime as rt
|
10 |
-
import PIL
|
11 |
-
import PIL.ImageColor
|
12 |
import tqdm
|
13 |
from huggingface_hub import hf_hub_download
|
14 |
|
@@ -18,6 +17,19 @@ from midi_tokenizer import MIDITokenizer
|
|
18 |
|
19 |
in_space = os.getenv("SYSTEM") == "spaces"
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
def softmax(x, axis):
|
22 |
x_max = np.amax(x, axis=axis, keepdims=True)
|
23 |
exp_x_shifted = np.exp(x - x_max)
|
|
|
1 |
import argparse
|
2 |
import glob
|
|
|
3 |
import os.path
|
4 |
+
|
5 |
+
import PIL
|
6 |
+
import PIL.ImageColor
|
7 |
import gradio as gr
|
8 |
+
import gradio_client.utils as gr_processing_utils
|
9 |
import numpy as np
|
10 |
import onnxruntime as rt
|
|
|
|
|
11 |
import tqdm
|
12 |
from huggingface_hub import hf_hub_download
|
13 |
|
|
|
17 |
|
18 |
in_space = os.getenv("SYSTEM") == "spaces"
|
19 |
|
20 |
+
audio_postprocess_ori = gr.Audio.postprocess
|
21 |
+
|
22 |
+
|
23 |
+
def audio_postprocess(self, y):
|
24 |
+
data = audio_postprocess_ori(self, y)
|
25 |
+
if data is None:
|
26 |
+
return None
|
27 |
+
return gr_processing_utils.encode_url_or_file_to_base64(data["name"])
|
28 |
+
|
29 |
+
|
30 |
+
gr.Audio.postprocess = audio_postprocess
|
31 |
+
|
32 |
+
|
33 |
def softmax(x, axis):
|
34 |
x_max = np.amax(x, axis=axis, keepdims=True)
|
35 |
exp_x_shifted = np.exp(x - x_max)
|