alibabasglab commited on
Commit
3956066
·
verified ·
1 Parent(s): bdaf47a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -17
app.py CHANGED
@@ -6,28 +6,29 @@ from clearvoice import ClearVoice
6
  myClearVoice = ClearVoice(task='speech_enhancement', model_names=['FRCRN_SE_16K'])
7
 
8
  def fn_clearvoice(aud):
9
- # Load and add fake batch dimension
10
- """
11
- noisy = enhance_model.load_audio(
12
- aud
13
- ).unsqueeze(0)
14
- enhanced = enhance_model.enhance_batch(noisy, lengths=torch.tensor([1.]))
15
- """
16
  output_wav_dict = myClearVoice(input_path='input.wav', online_write=False)
17
  if isinstance(output_wav_dict, dict):
18
  key = next(iter(output_wav_dict))
19
  output_wav = output_wav_dict[key]
20
  else:
21
  output_wav = output_wav_dict
22
- sf.write('enhanced.wav', output_wav, 16000)
23
  return 'enhanced.wav'
24
 
25
- inputs = gr.Audio(sources=["upload"], label="Input Audio", type="filepath")
26
- outputs = gr.Audio(label="Output Audio", type="filepath")
27
- title = "ClearVoice"
28
- description = "Gradio demo for Speech enhancement with ClearVoice. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below."
29
- article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2206.07293' target='_blank'>FRCRN: Boosting Feature Representation Using Frequency Recurrence for Monaural Speech Enhancement</a> | <a href='https://github.com/speechbrain/speechbrain' target='_blank'>Github Repo</a></p>"
30
- examples = [
31
- ['input.wav']
32
- ]
33
- gr.Interface(fn_clearvoice, inputs, outputs, title=title, description=description, article=article, examples=examples).launch()
 
 
 
 
 
 
 
 
 
6
  myClearVoice = ClearVoice(task='speech_enhancement', model_names=['FRCRN_SE_16K'])
7
 
8
  def fn_clearvoice(aud):
 
 
 
 
 
 
 
9
  output_wav_dict = myClearVoice(input_path='input.wav', online_write=False)
10
  if isinstance(output_wav_dict, dict):
11
  key = next(iter(output_wav_dict))
12
  output_wav = output_wav_dict[key]
13
  else:
14
  output_wav = output_wav_dict
15
+ #sf.write('enhanced.wav', output_wav, 16000)
16
  return 'enhanced.wav'
17
 
18
+ se_demo = gr.Interface(
19
+ fn=fn_clearvoice,
20
+ inputs = [
21
+ gr.Audio(sources=["upload"], label="Input Audio", type="filepath")
22
+ ],
23
+ outputs = [
24
+ gr.Audio(label="Output Audio", type="filepath")
25
+ ],
26
+ title = "ClearVoice",
27
+ description = ("Gradio demo for Speech enhancement with ClearVoice. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below."),
28
+ article = ("<p style='text-align: center'><a href='https://arxiv.org/abs/2206.07293' target='_blank'>FRCRN: Boosting Feature Representation Using Frequency Recurrence for Monaural Speech Enhancement</a> | <a href='https://github.com/speechbrain/speechbrain' target='_blank'>Github Repo</a></p>"),
29
+ examples = [
30
+ ['input.wav']
31
+ ]
32
+ cache_examples = True,
33
+ )
34
+ se_demo.launch()