Nephele commited on
Commit
a592a00
1 Parent(s): 95991a4

some_improve

Browse files
app.py CHANGED
@@ -1,12 +1,13 @@
1
  from audio_denoiser.AudioDenoiser import AudioDenoiser
2
  from timeit import default_timer as timer
 
3
  import gradio as gr
4
  from torchaudio import AudioMetaData
5
  import torch
6
  import tempfile
7
- import os
8
-
9
 
 
10
  theme='remilia/Ghostly'
11
  device = torch.device('cuda:0') if torch.cuda.is_available() else torch.device('cpu')
12
 
@@ -15,21 +16,31 @@ def denoiser(win, auto_scale):
15
  if win is None:
16
  gr.Warning('Audio does not exist. Please ensure that the audio has been successfully uploaded.')
17
  return None,None
18
-
19
  startTime=timer()
20
  denoiser = AudioDenoiser(device=device)
21
  temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.wav')
22
  wout = temp_file.name
23
  temp_file.close()
24
- denoiser.process_audio_file(win, wout, auto_scale)
 
 
 
 
 
25
  endTime=timer()
26
  info=(f'🆗Completion time: {round(endTime-startTime,4)}s')
 
 
27
  return wout,info
28
 
29
-
 
 
 
30
  with gr.Blocks(theme=theme) as app:
31
  gr.HTML('''
32
- <h1 style="font-size: 25px;">Audio Dnoiser</h1>
33
  <p style="margin-bottom: 10px; font-size: 100%">
34
 
35
  Originating from the project: <a href='https://github.com/jose-solorzano/audio-denoiser'>audio-denoiser</a><br>
@@ -47,8 +58,12 @@ model: <a href='https://huggingface.co/jose-h-solorzano/audio-denoiser-512-32-v1
47
  info=gr.Textbox(label='info')
48
 
49
  btn.click(
50
- denoiser,
51
- inputs=[audio_in, scale],
52
- outputs=[audio_out,info])
 
 
 
 
53
 
54
  app.launch(share=True)
 
1
  from audio_denoiser.AudioDenoiser import AudioDenoiser
2
  from timeit import default_timer as timer
3
+ from datetime import datetime
4
  import gradio as gr
5
  from torchaudio import AudioMetaData
6
  import torch
7
  import tempfile
8
+ import os,pytz
 
9
 
10
+ tz = pytz.timezone('Asia/Singapore')
11
  theme='remilia/Ghostly'
12
  device = torch.device('cuda:0') if torch.cuda.is_available() else torch.device('cpu')
13
 
 
16
  if win is None:
17
  gr.Warning('Audio does not exist. Please ensure that the audio has been successfully uploaded.')
18
  return None,None
19
+
20
  startTime=timer()
21
  denoiser = AudioDenoiser(device=device)
22
  temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.wav')
23
  wout = temp_file.name
24
  temp_file.close()
25
+ try:
26
+ denoiser.process_audio_file(win, wout, auto_scale)
27
+ except RuntimeError as e:
28
+ gr.Warning(str(e))
29
+ return None,None
30
+
31
  endTime=timer()
32
  info=(f'🆗Completion time: {round(endTime-startTime,4)}s')
33
+ now=datetime.now(tz).strftime('%H:%M:%S')
34
+ print(f'{now}-{info}')
35
  return wout,info
36
 
37
+ examples = [
38
+ ["sample/exp1.wav", "sample/exp1_d.wav"],
39
+ ["sample/exp2.wav", "sample/exp2_d.wav"]
40
+ ]
41
  with gr.Blocks(theme=theme) as app:
42
  gr.HTML('''
43
+ <h1 style="font-size: 25px;">Audio Denoiser</h1>
44
  <p style="margin-bottom: 10px; font-size: 100%">
45
 
46
  Originating from the project: <a href='https://github.com/jose-solorzano/audio-denoiser'>audio-denoiser</a><br>
 
58
  info=gr.Textbox(label='info')
59
 
60
  btn.click(
61
+ denoiser,
62
+ inputs=[audio_in, scale],
63
+ outputs=[audio_out,info])
64
+
65
+ examples = gr.Examples(examples=examples, inputs=audio_in, outputs=audio_out, fn=denoiser)
66
+
67
+
68
 
69
  app.launch(share=True)
sample/{noise2.wav → exp1.wav} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c8e4445aed300ec8954d00aed652fdc1043b6dcdbf9d896414125fa4b513a5b9
3
- size 441044
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d79018dd06ac5bdcb27517d60ba30d61cf93b4842505d63b3986058224c6607
3
+ size 1318990
sample/{noise1.wav → exp2.wav} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ad861d15fffc0a933a839cc4730b5e42d56a86084f686f130451c7134c8ed26f
3
- size 438100
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8ca61a37ea9c3172629f71b36029eb2268b78542455f6e942bb7926e5fa2cf8
3
+ size 737358
sample/noise3.wav DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b5664d57114d9d81d561919493b91fca1a994679fdbaec24ece60eb2fd406afa
3
- size 790316