jadechoghari commited on
Commit
c5d5c61
โ€ข
1 Parent(s): 845df18

add new ckpt

Browse files
Files changed (3) hide show
  1. app.py +21 -7
  2. pytorch_model.bin +1 -1
  3. restored_output.wav +0 -0
app.py CHANGED
@@ -11,22 +11,36 @@ model = AutoModel.from_pretrained(checkpoint_path, trust_remote_code=True)
11
 
12
  @spaces.GPU()
13
  def restore_audio(input_audio):
14
- # load the audio file
 
 
 
 
 
 
15
  output_path = "restored_output.wav"
16
- model(input_audio, output_path)
 
 
 
 
 
17
  return output_path
18
 
19
 
20
  with gr.Blocks() as demo:
21
- gr.Markdown("<h1 style='text-align: center;'>๐Ÿ”Š Voice Restoration with Transformer-based Model</h1>")
22
  gr.Markdown(
23
  """
24
- <p style='text-align: center;'>Upload a degraded audio file or select an example, and the space will restore it using the <b>VoiceRestore</b> model!<br>
25
- Based on this <a href='https://github.com/skirdey/voicerestore' target='_blank'>repo</a> by <a href='https://github.com/skirdey' target='_blank'>@Stan Kirdey</a>,<br>
26
- and the HF Transformers ๐Ÿค— model by <a href='https://github.com/jadechoghari' target='_blank'>@jadechoghari</a>.
27
- </p>
 
 
28
  """
29
  )
 
30
 
31
  with gr.Row():
32
  with gr.Column():
 
11
 
12
  @spaces.GPU()
13
  def restore_audio(input_audio):
14
+ # Load the audio file
15
+ waveform, sample_rate = torchaudio.load(input_audio)
16
+
17
+ # Calculate the duration of the audio (in seconds)
18
+ duration = waveform.shape[1] / sample_rate
19
+
20
+ # Output file path
21
  output_path = "restored_output.wav"
22
+
23
+ if duration > 10:
24
+ model(input_audio, output_path, short=False)
25
+ else:
26
+ model(input_audio, output_path) # short=True by default
27
+
28
  return output_path
29
 
30
 
31
  with gr.Blocks() as demo:
32
+ gr.Markdown("# ๐Ÿ”Š Voice Restoration with Transformer-based Model")
33
  gr.Markdown(
34
  """
35
+ Upload a degraded audio file or select an example, and the space will restore it using the **VoiceRestore** model!
36
+
37
+ Based on this [repo](https://github.com/skirdey/voicerestore) by [@Stan Kirdey](https://github.com/skirdey),
38
+ and the HF Transformers ๐Ÿค— [Model](https://huggingface.co/jadechoghari/VoiceRestore) by [@jadechoghari](https://github.com/jadechoghari).
39
+
40
+ The model returns optimized results for audio less than 10 seconds, however, it supports unlimited duration!
41
  """
42
  )
43
+
44
 
45
  with gr.Row():
46
  with gr.Column():
pytorch_model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:556a83f119c828d0a6ee47bc84149403fd4428eb755bcc222169a68eaa4443dd
3
  size 1204445470
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d8ebdc57b002abd36d71ea2d5d0955380b46f283b7953baaf3bcb09f67ad135
3
  size 1204445470
restored_output.wav ADDED
Binary file (279 kB). View file