Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,10 @@ import tempfile
|
|
| 4 |
import os
|
| 5 |
import soundfile as sf
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def run(cmd):
|
| 8 |
subprocess.check_call(cmd, shell=True)
|
| 9 |
|
|
@@ -19,19 +23,10 @@ def morph_audio(wav_a, wav_b, morph_amt):
|
|
| 19 |
sf.write(a_wav, wav_a[1], wav_a[0])
|
| 20 |
sf.write(b_wav, wav_b[1], wav_b[0])
|
| 21 |
|
| 22 |
-
|
| 23 |
-
run(f"
|
| 24 |
-
run(f"
|
| 25 |
-
|
| 26 |
-
# Morph (linear interpolation)
|
| 27 |
-
run(
|
| 28 |
-
f"loris_morph "
|
| 29 |
-
f"--alpha {morph_amt} "
|
| 30 |
-
f"{a_sdif} {b_sdif} {m_sdif}"
|
| 31 |
-
)
|
| 32 |
-
|
| 33 |
-
# Synthesize
|
| 34 |
-
run(f"loris_synthesize {m_sdif} {out_wav}")
|
| 35 |
|
| 36 |
data, sr = sf.read(out_wav)
|
| 37 |
return sr, data
|
|
@@ -45,7 +40,7 @@ ui = gr.Interface(
|
|
| 45 |
],
|
| 46 |
outputs=gr.Audio(label="Morphed Output"),
|
| 47 |
title="Loris Audio Morphing (SDIF)",
|
| 48 |
-
description="Deterministisk sinusoidal morphing med Loris + SDIF"
|
| 49 |
)
|
| 50 |
|
| 51 |
ui.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
| 4 |
import os
|
| 5 |
import soundfile as sf
|
| 6 |
|
| 7 |
+
LORIS_ANALYZE = "/usr/local/bin/loris_analyze"
|
| 8 |
+
LORIS_MORPH = "/usr/local/bin/loris_morph"
|
| 9 |
+
LORIS_SYNTH = "/usr/local/bin/loris_synthesize"
|
| 10 |
+
|
| 11 |
def run(cmd):
|
| 12 |
subprocess.check_call(cmd, shell=True)
|
| 13 |
|
|
|
|
| 23 |
sf.write(a_wav, wav_a[1], wav_a[0])
|
| 24 |
sf.write(b_wav, wav_b[1], wav_b[0])
|
| 25 |
|
| 26 |
+
run(f"{LORIS_ANALYZE} {a_wav} {a_sdif}")
|
| 27 |
+
run(f"{LORIS_ANALYZE} {b_wav} {b_sdif}")
|
| 28 |
+
run(f"{LORIS_MORPH} --alpha {morph_amt} {a_sdif} {b_sdif} {m_sdif}")
|
| 29 |
+
run(f"{LORIS_SYNTH} {m_sdif} {out_wav}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
data, sr = sf.read(out_wav)
|
| 32 |
return sr, data
|
|
|
|
| 40 |
],
|
| 41 |
outputs=gr.Audio(label="Morphed Output"),
|
| 42 |
title="Loris Audio Morphing (SDIF)",
|
|
|
|
| 43 |
)
|
| 44 |
|
| 45 |
ui.launch(server_name="0.0.0.0", server_port=7860)
|
| 46 |
+
|