Hobis commited on
Commit
45caaa1
1 Parent(s): 8fa79f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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(audio_file):
14
  hubert_model = CustomHubert(checkpoint_path='hubert.pt')
15
- wav, sr = torchaudio.load(audio_file)
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(input_audio):
34
- processed_file = process_audio('audio.wav')
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
+