lab commited on
Commit
e4a6b5c
·
verified ·
1 Parent(s): a12f3e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -35
app.py CHANGED
@@ -1,41 +1,10 @@
1
- import torch
2
- import torchaudio
3
  import gradio as gr
4
- import requests
5
 
6
- # Download and load the HuBERT content encoder
7
- hubert = torch.hub.load("bshall/hubert:main", "hubert_soft", trust_repo=True).cuda()
8
 
9
- # Assuming similar steps for downloading and loading the acoustic model
10
- acoustic_model = torch.hub.load("bshall/acoustic-model:main", "hubert_soft", trust_repo=True).cuda()
11
 
12
- # Load the HiFiGAN vocoder (if used in the notebook)
13
- vocoder = torch.hub.load("bshall/hifigan:main", "hifigan", trust_repo=True).cuda()
14
 
15
- def voice_conversion(input_audio):
16
- # Load input audio
17
- waveform, sample_rate = torchaudio.load(input_audio)
18
-
19
- # Process the audio using the models
20
- with torch.no_grad():
21
- units = hubert(waveform.cuda())
22
- mel_spec = acoustic_model.generate(units)
23
- audio_out = vocoder(mel_spec)
24
-
25
- # Save the output audio
26
- output_path = "output.wav"
27
- torchaudio.save(output_path, audio_out.cpu(), sample_rate)
28
-
29
- return output_path
30
 
31
- # Define Gradio interface
32
- iface = gr.Interface(
33
- fn=voice_conversion,
34
- inputs=gr.inputs.Audio(source="upload", type="filepath"),
35
- outputs=gr.outputs.Audio(type="file"),
36
- title="Voice Conversion Demo",
37
- description="Upload an audio file to convert its voice using HuBERT and other models."
38
- )
39
-
40
- # Launch the interface
41
- iface.launch()
 
 
 
1
  import gradio as gr
 
2
 
 
 
3
 
4
+ def greet(name):
5
+ return "Hello " + name + "!!"
6
 
7
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
8
+ demo.launch()
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10