From d2c1204d91d7c98be7998e3966bd82e22750293b Mon Sep 17 00:00:00 2001
From: zhifu gao <zhifu.gzf@alibaba-inc.com>
Date: 星期一, 04 三月 2024 17:50:29 +0800
Subject: [PATCH] Revert "Dev yf" (#1418)
---
funasr/frontends/default.py | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/funasr/frontends/default.py b/funasr/frontends/default.py
index 66d42f7..8ac1ca8 100644
--- a/funasr/frontends/default.py
+++ b/funasr/frontends/default.py
@@ -3,6 +3,7 @@
from typing import Tuple
from typing import Union
import logging
+import humanfriendly
import numpy as np
import torch
import torch.nn as nn
@@ -15,10 +16,8 @@
from funasr.frontends.utils.stft import Stft
from funasr.frontends.utils.frontend import Frontend
from funasr.models.transformer.utils.nets_utils import make_pad_mask
-from funasr.register import tables
-@tables.register("frontend_classes", "DefaultFrontend")
class DefaultFrontend(nn.Module):
"""Conventional frontend structure for ASR.
Stft -> WPE -> MVDR-Beamformer -> Power-spec -> Mel-Fbank -> CMVN
@@ -26,7 +25,7 @@
def __init__(
self,
- fs: int = 16000,
+ fs: Union[int, str] = 16000,
n_fft: int = 512,
win_length: int = None,
hop_length: int = 128,
@@ -41,9 +40,10 @@
frontend_conf: Optional[dict] = None,
apply_stft: bool = True,
use_channel: int = None,
- **kwargs,
):
super().__init__()
+ if isinstance(fs, str):
+ fs = humanfriendly.parse_size(fs)
# Deepcopy (In general, dict shouldn't be used as default arg)
frontend_conf = copy.deepcopy(frontend_conf)
@@ -145,7 +145,7 @@
def __init__(
self,
- fs: int = 16000,
+ fs: Union[int, str] = 16000,
n_fft: int = 512,
win_length: int = None,
hop_length: int = None,
@@ -168,6 +168,9 @@
mc: bool = True
):
super().__init__()
+ if isinstance(fs, str):
+ fs = humanfriendly.parse_size(fs)
+
# Deepcopy (In general, dict shouldn't be used as default arg)
frontend_conf = copy.deepcopy(frontend_conf)
if win_length is None and hop_length is None:
--
Gitblit v1.9.1