Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sgmse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Svajda, Till
sgmse
Commits
636a70e9
Commit
636a70e9
authored
10 months ago
by
jrichter
Browse files
Options
Downloads
Patches
Plain Diff
resampling if sr is not target sr
parent
215325c4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
enhancement.py
+10
-4
10 additions, 4 deletions
enhancement.py
with
10 additions
and
4 deletions
enhancement.py
+
10
−
4
View file @
636a70e9
...
...
@@ -6,6 +6,7 @@ from soundfile import write
from
torchaudio
import
load
from
os.path
import
join
,
dirname
from
argparse
import
ArgumentParser
from
librosa
import
resample
# Set CUDA architecture list
from
sgmse.util.other
import
set_torch_cuda_arch_list
...
...
@@ -38,10 +39,10 @@ if __name__ == '__main__':
# Check if the model is trained on 48 kHz data
if
model
.
backbone
==
'
ncsnpp_48k
'
:
sr
=
48000
target_
sr
=
48000
pad_mode
=
"
reflection
"
else
:
sr
=
16000
target_
sr
=
16000
pad_mode
=
"
zero_pad
"
# Enhance files
...
...
@@ -50,7 +51,12 @@ if __name__ == '__main__':
filename
=
noisy_file
.
replace
(
args
.
test_dir
,
""
)[
1
:]
# Remove the first character which is a slash
# Load wav
y
,
_
=
load
(
noisy_file
)
y
,
sr
=
load
(
noisy_file
)
# Resample if necessary
if
sr
!=
target_sr
:
y
=
resample
(
y
,
orig_sr
=
sr
,
target_sr
=
target_sr
)
T_orig
=
y
.
size
(
1
)
# Normalize
...
...
@@ -75,4 +81,4 @@ if __name__ == '__main__':
# Write enhanced wav file
makedirs
(
dirname
(
join
(
args
.
enhanced_dir
,
filename
)),
exist_ok
=
True
)
write
(
join
(
args
.
enhanced_dir
,
filename
),
x_hat
.
cpu
().
numpy
(),
sr
)
write
(
join
(
args
.
enhanced_dir
,
filename
),
x_hat
.
cpu
().
numpy
(),
target_
sr
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment