Spaces:
Running
Running
Commit
·
0f8dcae
1
Parent(s):
8230fbf
eighth commit
Browse files- .gitignore +1 -0
- app.py +32 -32
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.vscode*
|
app.py
CHANGED
@@ -44,6 +44,33 @@ def separate_track_with_model(
|
|
44 |
return estimates
|
45 |
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
def main(input, mix_coefficient):
|
48 |
parser = argparse.ArgumentParser(description="model test.py")
|
49 |
parser.add_argument("--target", type=str, default="all")
|
@@ -143,45 +170,18 @@ def main(input, mix_coefficient):
|
|
143 |
)
|
144 |
|
145 |
# if args.save_mixed_output:
|
146 |
-
|
|
|
147 |
augmented_gain = args.save_output_loudnorm - track_lufs
|
148 |
orig_audio = orig_audio * db2linear(augmented_gain, eps=0.0)
|
149 |
|
150 |
return (
|
151 |
(sr, estimates.T),
|
152 |
-
(sr, orig_audio),
|
153 |
-
(sr, orig_audio * mix_coefficient + estimates.T * (1 - mix_coefficient)),
|
154 |
)
|
155 |
|
156 |
|
157 |
-
def parallel_mix(input, output, mix_coefficient):
|
158 |
-
sr = 44100
|
159 |
-
return sr, input[1] * mix_coefficient + output[1] * (1 - mix_coefficient)
|
160 |
-
|
161 |
-
|
162 |
-
def int16_to_float32(wav):
|
163 |
-
wav = np.frombuffer(wav, dtype=np.int16)
|
164 |
-
X = wav / 32768
|
165 |
-
return X
|
166 |
-
|
167 |
-
|
168 |
-
def waveform_plot(input, output, prl_mix_ouptut, figsize_x=20, figsize_y=9):
|
169 |
-
sr = 44100
|
170 |
-
fig, ax = plt.subplots(
|
171 |
-
nrows=3, sharex=True, sharey=True, figsize=(figsize_x, figsize_y)
|
172 |
-
)
|
173 |
-
librosa.display.waveshow(int16_to_float32(input[1]).T, sr=sr, ax=ax[0])
|
174 |
-
ax[0].set(title="Loudness Normalized Input")
|
175 |
-
ax[0].label_outer()
|
176 |
-
librosa.display.waveshow(int16_to_float32(output[1]).T, sr=sr, ax=ax[1])
|
177 |
-
ax[1].set(title="De-limiter Output")
|
178 |
-
ax[1].label_outer()
|
179 |
-
librosa.display.waveshow(int16_to_float32(prl_mix_ouptut[1]).T, sr=sr, ax=ax[2])
|
180 |
-
ax[2].set(title="Parallel Mix of the Input and its De-limiter Output")
|
181 |
-
ax[2].label_outer()
|
182 |
-
return fig
|
183 |
-
|
184 |
-
|
185 |
with gr.Blocks() as demo:
|
186 |
gr.HTML(
|
187 |
"""
|
@@ -203,7 +203,7 @@ with gr.Blocks() as demo:
|
|
203 |
You can first upload a music (.wav or .mp3) file and then press "De-limit" button to apply the De-limiter. Since we use a CPU instead of a GPU, it may require a few minute.
|
204 |
Then, you can apply a Parallel Mix technique, which is a simple linear mixing technique of "loudness normalized input" and the "de-limiter output".
|
205 |
You can modify the mixing coefficient by yourself.
|
206 |
-
If the coefficient is 0.3 then the output will be
|
207 |
</div>
|
208 |
"""
|
209 |
)
|
|
|
44 |
return estimates
|
45 |
|
46 |
|
47 |
+
def parallel_mix(input, output, mix_coefficient):
|
48 |
+
sr = 44100
|
49 |
+
return sr, input[1] * mix_coefficient + output[1] * (1 - mix_coefficient)
|
50 |
+
|
51 |
+
|
52 |
+
def int16_to_float32(wav):
|
53 |
+
X = wav / 32768
|
54 |
+
return X
|
55 |
+
|
56 |
+
|
57 |
+
def waveform_plot(input, output, prl_mix_ouptut, figsize_x=20, figsize_y=9):
|
58 |
+
sr = 44100
|
59 |
+
fig, ax = plt.subplots(
|
60 |
+
nrows=3, sharex=True, sharey=True, figsize=(figsize_x, figsize_y)
|
61 |
+
)
|
62 |
+
librosa.display.waveshow(int16_to_float32(input[1]).T, sr=sr, ax=ax[0])
|
63 |
+
ax[0].set(title="Loudness Normalized Input")
|
64 |
+
ax[0].label_outer()
|
65 |
+
librosa.display.waveshow(int16_to_float32(output[1]).T, sr=sr, ax=ax[1])
|
66 |
+
ax[1].set(title="De-limiter Output")
|
67 |
+
ax[1].label_outer()
|
68 |
+
librosa.display.waveshow(int16_to_float32(prl_mix_ouptut[1]).T, sr=sr, ax=ax[2])
|
69 |
+
ax[2].set(title="Parallel Mix of the Input and its De-limiter Output")
|
70 |
+
ax[2].label_outer()
|
71 |
+
return fig
|
72 |
+
|
73 |
+
|
74 |
def main(input, mix_coefficient):
|
75 |
parser = argparse.ArgumentParser(description="model test.py")
|
76 |
parser.add_argument("--target", type=str, default="all")
|
|
|
170 |
)
|
171 |
|
172 |
# if args.save_mixed_output:
|
173 |
+
orig_audio = int16_to_float32(orig_audio)
|
174 |
+
track_lufs = meter.integrated_loudness(orig_audio.T)
|
175 |
augmented_gain = args.save_output_loudnorm - track_lufs
|
176 |
orig_audio = orig_audio * db2linear(augmented_gain, eps=0.0)
|
177 |
|
178 |
return (
|
179 |
(sr, estimates.T),
|
180 |
+
(sr, orig_audio.T),
|
181 |
+
(sr, orig_audio.T * mix_coefficient + estimates.T * (1 - mix_coefficient)),
|
182 |
)
|
183 |
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
with gr.Blocks() as demo:
|
186 |
gr.HTML(
|
187 |
"""
|
|
|
203 |
You can first upload a music (.wav or .mp3) file and then press "De-limit" button to apply the De-limiter. Since we use a CPU instead of a GPU, it may require a few minute.
|
204 |
Then, you can apply a Parallel Mix technique, which is a simple linear mixing technique of "loudness normalized input" and the "de-limiter output".
|
205 |
You can modify the mixing coefficient by yourself.
|
206 |
+
If the coefficient is 0.3 then the output will be "loudness_normalized_input * 0.3 + de-limiter_output * 0.7"
|
207 |
</div>
|
208 |
"""
|
209 |
)
|