alibabasglab commited on
Commit
b78b7d0
·
verified ·
1 Parent(s): 3192961

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -4
app.py CHANGED
@@ -3,9 +3,10 @@ import soundfile as sf
3
  import gradio as gr
4
  from clearvoice import ClearVoice
5
 
6
- myClearVoice = ClearVoice(task='speech_enhancement', model_names=['FRCRN_SE_16K'])
7
 
8
- def fn_clearvoice(input_wav):
 
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))
@@ -15,17 +16,46 @@ def fn_clearvoice(input_wav):
15
  sf.write('enhanced.wav', output_wav, 16000)
16
  return 'enhanced.wav'
17
 
 
 
 
 
 
 
 
 
 
 
 
18
  demo = gr.Blocks()
19
 
20
  se_demo = gr.Interface(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  fn=fn_clearvoice,
22
  inputs = [
23
  gr.Audio(label="Input Audio", type="filepath")
24
  ],
25
  outputs = [
26
  gr.Audio(label="Output Audio", type="filepath")
 
27
  ],
28
- title = "ClearVoice",
29
  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."),
30
  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>"),
31
  examples = [
@@ -33,6 +63,7 @@ se_demo = gr.Interface(
33
  ],
34
  cache_examples = True,
35
  )
 
36
  with demo:
37
- gr.TabbedInterface([se_demo, se_demo], ["Speech Enhancement", "Speech Separation"])
38
  demo.launch()
 
3
  import gradio as gr
4
  from clearvoice import ClearVoice
5
 
6
+ #myClearVoice = ClearVoice(task='speech_enhancement', model_names=['FRCRN_SE_16K'])
7
 
8
+ def fn_clearvoice_se(input_wav):
9
+ myClearVoice = ClearVoice(task='speech_enhancement', model_names=['FRCRN_SE_16K'])
10
  output_wav_dict = myClearVoice(input_path=input_wav, online_write=False)
11
  if isinstance(output_wav_dict, dict):
12
  key = next(iter(output_wav_dict))
 
16
  sf.write('enhanced.wav', output_wav, 16000)
17
  return 'enhanced.wav'
18
 
19
+ def fn_clearvoice_ss(input_wav):
20
+ myClearVoice = ClearVoice(task='speech_separation', model_names=['MossFormer2_SS_16K'])
21
+ output_wav_dict = myClearVoice(input_path=input_wav, online_write=False)
22
+ if isinstance(output_wav_dict, dict):
23
+ key = next(iter(output_wav_dict))
24
+ output_wav = output_wav_dict[key]
25
+ else:
26
+ output_wav = output_wav_dict
27
+ sf.write('separated_1.wav', output_wav, 16000)
28
+ return 'separated_1.wav'
29
+
30
  demo = gr.Blocks()
31
 
32
  se_demo = gr.Interface(
33
+ fn=fn_clearvoice_se,
34
+ inputs = [
35
+ gr.Audio(label="Input Audio", type="filepath")
36
+ ],
37
+ outputs = [
38
+ gr.Audio(label="Output Audio", type="filepath")
39
+ ],
40
+ title = "ClearVoice: Speech Enhancement",
41
+ 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."),
42
+ 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>"),
43
+ examples = [
44
+ ['mandarin_speech.wav']
45
+ ],
46
+ cache_examples = True,
47
+ )
48
+
49
+ ss_demo = gr.Interface(
50
  fn=fn_clearvoice,
51
  inputs = [
52
  gr.Audio(label="Input Audio", type="filepath")
53
  ],
54
  outputs = [
55
  gr.Audio(label="Output Audio", type="filepath")
56
+ gr.Audio(label="Output Audio", type="filepath")
57
  ],
58
+ title = "ClearVoice: Speech Separation",
59
  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."),
60
  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>"),
61
  examples = [
 
63
  ],
64
  cache_examples = True,
65
  )
66
+
67
  with demo:
68
+ gr.TabbedInterface([se_demo, ss_demo], ["Speech Enhancement", "Speech Separation"])
69
  demo.launch()