Skip to content

Commit

Permalink
[lint] fix fake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cdliang11 committed Sep 4, 2024
1 parent 8fc89c8 commit 224db3e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions wesep/bin/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def infer(config="confs/conf.yaml", **kwargs):
if not os.path.exists(save_audio_dir):
try:
os.makedirs(save_audio_dir)
print(f"Directory '{save_audio_dir}' created successfully.")
print(f"Directory {save_audio_dir} created successfully.")
except OSError as e:
print(f"Error creating directory '{save_audio_dir}': {e}")
print(f"Error creating directory {save_audio_dir}: {e}")
else:
print(f"Directory '{save_audio_dir}' already exists.")
print(f"Directory {save_audio_dir} already exists.")
else:
print("Do NOT save the results in wav.")

Expand Down
6 changes: 3 additions & 3 deletions wesep/bin/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ def scoring(

if not Path(dnsmos_args["primary_model"]).exists():
raise ValueError(
f"The primary model '{dnsmos_args['primary_model']}' doesn't exist."
f"The primary model {dnsmos_args['primary_model']} doesn't exist."
" You can download the model from https://github.com/microsoft/"
"DNS-Challenge/tree/master/DNSMOS/DNSMOS/sig_bak_ovr.onnx")
if not Path(dnsmos_args["p808_model"]).exists():
raise ValueError(
f"The P808 model '{dnsmos_args['p808_model']}' doesn't exist."
f"The P808 model {dnsmos_args['p808_model']} doesn't exist."
" You can download the model from https://github.com/microsoft/"
"DNS-Challenge/tree/master/DNSMOS/DNSMOS/model_v8.onnx")
dnsmos = DNSMOS_local(
Expand Down Expand Up @@ -90,7 +90,7 @@ def scoring(
logging.warning("Using the PESQ package for evaluation")
except ImportError:
raise ImportError(
"Please install pesq and retry: pip install pesq")
"Please install pesq and retry: pip install pesq") from None
else:
pesq = None

Expand Down
2 changes: 1 addition & 1 deletion wesep/modules/common/norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def select_norm(norm, dim):

class FiLM(nn.Module):
"""Feature-wise Linear Modulation (FiLM) layer
https://github.com/HuangZiliAndy/fairseq/blob/multispk/fairseq/models/wavlm/WavLM.py#L1160
https://github.com/HuangZiliAndy/fairseq/blob/multispk/fairseq/models/wavlm/WavLM.py#L1160 # noqa
"""

def __init__(self,
Expand Down
10 changes: 4 additions & 6 deletions wesep/modules/tfgridnet/gridnet_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,10 @@ def forward(self, x):
B, C, old_T, old_Q = x.shape

olp = self.emb_ks - self.emb_hs
T = (math.ceil(
(old_T + 2 * olp - self.emb_ks) / self.emb_hs) * self.emb_hs +
self.emb_ks)
Q = (math.ceil(
(old_Q + 2 * olp - self.emb_ks) / self.emb_hs) * self.emb_hs +
self.emb_ks)
T = math.ceil((old_T + 2 * olp - self.emb_ks) /
self.emb_hs) * self.emb_hs + self.emb_ks
Q = math.ceil((old_Q + 2 * olp - self.emb_ks) /
self.emb_hs) * self.emb_hs + self.emb_ks

x = x.permute(0, 2, 3, 1) # [B, old_T, old_Q, C]
x = F.pad(
Expand Down
4 changes: 2 additions & 2 deletions wesep/utils/dnsmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(
from onnx2torch import convert
except ModuleNotFoundError:
raise RuntimeError(
"Please install onnx2torch manually and retry!")
"Please install onnx2torch manually and retry!") from None

if primary_model_path is not None:
self.primary_model = convert(primary_model_path).eval()
Expand All @@ -99,7 +99,7 @@ def __init__(
import onnxruntime as ort
except ModuleNotFoundError:
raise RuntimeError(
"Please install onnxruntime manually and retry!")
"Please install onnxruntime manually and retry!") from None

prvd = ("CUDAExecutionProvider"
if use_gpu else "CPUExecutionProvider")
Expand Down
2 changes: 1 addition & 1 deletion wesep/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def soundfile_read(
if prev_wav is not None:
if prev_rate != rate:
raise RuntimeError(
f"'{prev_wav}' and '{wav}' have mismatched sampling rate: "
f"{prev_wav} and {wav} have mismatched sampling rate: "
f"{prev_rate} != {rate}")

dim1 = arrays[0].shape[1 - concat_axis]
Expand Down

0 comments on commit 224db3e

Please sign in to comment.