Update app.py
Browse files
app.py
CHANGED
@@ -10,9 +10,9 @@ from hubert.customtokenizer import CustomTokenizer
|
|
10 |
from encodec import EncodecModel
|
11 |
from encodec.utils import convert_audio
|
12 |
|
13 |
-
def process_audio(
|
14 |
hubert_model = CustomHubert(checkpoint_path='hubert.pt')
|
15 |
-
wav, sr = torchaudio.load(
|
16 |
if wav.shape[0] == 2:
|
17 |
wav = wav.mean(0, keepdim=True)
|
18 |
semantic_vectors = hubert_model.forward(wav, input_sample_hz=sr)
|
@@ -30,8 +30,8 @@ def process_audio(audio_file):
|
|
30 |
np.savez('helloWorld.npz', semantic_prompt=semantic_tokens, fine_prompt=fine_prompt, coarse_prompt=coarse_prompt)
|
31 |
return os.path.abspath('helloWorld.npz')
|
32 |
|
33 |
-
def audio_file_processing(
|
34 |
-
processed_file = process_audio(
|
35 |
return processed_file
|
36 |
|
37 |
audio_input = gr.inputs.Audio(label="Select an audio file")
|
@@ -40,3 +40,4 @@ audio_output = gr.outputs.File(label="Download")
|
|
40 |
gr.Interface(fn=audio_file_processing, inputs=audio_input, outputs=audio_output).launch()
|
41 |
|
42 |
|
|
|
|
10 |
from encodec import EncodecModel
|
11 |
from encodec.utils import convert_audio
|
12 |
|
13 |
+
def process_audio():
|
14 |
hubert_model = CustomHubert(checkpoint_path='hubert.pt')
|
15 |
+
wav, sr = torchaudio.load("audio.wav")
|
16 |
if wav.shape[0] == 2:
|
17 |
wav = wav.mean(0, keepdim=True)
|
18 |
semantic_vectors = hubert_model.forward(wav, input_sample_hz=sr)
|
|
|
30 |
np.savez('helloWorld.npz', semantic_prompt=semantic_tokens, fine_prompt=fine_prompt, coarse_prompt=coarse_prompt)
|
31 |
return os.path.abspath('helloWorld.npz')
|
32 |
|
33 |
+
def audio_file_processing():
|
34 |
+
processed_file = process_audio()
|
35 |
return processed_file
|
36 |
|
37 |
audio_input = gr.inputs.Audio(label="Select an audio file")
|
|
|
40 |
gr.Interface(fn=audio_file_processing, inputs=audio_input, outputs=audio_output).launch()
|
41 |
|
42 |
|
43 |
+
|