duongthienz commited on
Commit
510fb60
·
verified ·
1 Parent(s): aa72991

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -22
app.py CHANGED
@@ -20,10 +20,8 @@ import torch
20
  #import torch_xla.core.xla_model as xm
21
  from pyannote.audio import Pipeline
22
  from pyannote.core import Annotation, Segment, Timeline
23
- from df.enhance import enhance, init_df
24
  import datetime as dt
25
 
26
- enableDenoise = False
27
  earlyCleanup = True
28
 
29
  # [None,Low,Medium,High,Debug]
@@ -68,27 +66,13 @@ def save_data(
68
  scheduler.append(data)
69
 
70
  def processFile(filePath):
71
- global attenLimDb
72
  global gainWindow
73
  global minimumGain
74
  global maximumGain
75
  print("Loading file")
76
  waveformList, sampleRate = su.splitIntoTimeSegments(filePath,600)
77
  print("File loaded")
78
- enhancedWaveformList = []
79
- if (enableDenoise):
80
- print("Denoising")
81
- for w in waveformList:
82
- if (enableDenoise):
83
- newW = enhance(dfModel,dfState,w,atten_lim_db=attenLimDB).detach().cpu()
84
- enhancedWaveformList.append(newW)
85
- else:
86
- enhancedWaveformList.append(w)
87
- if (enableDenoise):
88
- print("Audio denoised")
89
- waveformEnhanced = su.combineWaveforms(enhancedWaveformList)
90
- if (earlyCleanup):
91
- del enhancedWaveformList
92
  print("Equalizing Audio")
93
  waveform_gain_adjusted = su.equalizeVolume()(waveformEnhanced,sampleRate,gainWindow,minimumGain,maximumGain)
94
  if (earlyCleanup):
@@ -287,7 +271,6 @@ secondDifference = 5
287
  gainWindow = 4
288
  minimumGain = -45
289
  maximumGain = -5
290
- attenLimDB = 3
291
 
292
  isGPU = False
293
 
@@ -304,10 +287,6 @@ except RuntimeError as e:
304
  print(f"Using {device} instead.")
305
  #device = xm.xla_device()
306
 
307
- if (enableDenoise):
308
- # Instantiate and prepare model for training.
309
- dfModel, dfState, _ = init_df(model_base_dir="DeepFilterNet3")
310
- dfModel.to(device)#torch.device("cuda"))
311
  pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1")
312
  pipeline.to(device)#torch.device("cuda"))
313
 
 
20
  #import torch_xla.core.xla_model as xm
21
  from pyannote.audio import Pipeline
22
  from pyannote.core import Annotation, Segment, Timeline
 
23
  import datetime as dt
24
 
 
25
  earlyCleanup = True
26
 
27
  # [None,Low,Medium,High,Debug]
 
66
  scheduler.append(data)
67
 
68
  def processFile(filePath):
 
69
  global gainWindow
70
  global minimumGain
71
  global maximumGain
72
  print("Loading file")
73
  waveformList, sampleRate = su.splitIntoTimeSegments(filePath,600)
74
  print("File loaded")
75
+ waveformEnhanced = su.combineWaveforms(waveformList)
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  print("Equalizing Audio")
77
  waveform_gain_adjusted = su.equalizeVolume()(waveformEnhanced,sampleRate,gainWindow,minimumGain,maximumGain)
78
  if (earlyCleanup):
 
271
  gainWindow = 4
272
  minimumGain = -45
273
  maximumGain = -5
 
274
 
275
  isGPU = False
276
 
 
287
  print(f"Using {device} instead.")
288
  #device = xm.xla_device()
289
 
 
 
 
 
290
  pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1")
291
  pipeline.to(device)#torch.device("cuda"))
292