Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
funasr_2607
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 257b750c
authored
Jul 29, 2026
by
王欣伟
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改:改用filter方式过滤热词日志
1 parent
a7b7e2f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
asr_service/utils.py
asr_service/utils.py
View file @
257b750
...
...
@@ -9,6 +9,20 @@ from logging.handlers import TimedRotatingFileHandler
from
.config
import
Config
class
_HotwordLogFilter
(
logging
.
Filter
):
"""屏蔽 funasr 热词解析的刷屏日志。
funasr 的 seaco_paraformer/contextual_paraformer 用 logging.info() 直接调
root logger(不是模块 logger),无法按 logger 名屏蔽,只能在 root logger
上加 filter 按消息内容过滤。
"""
_BLOCKED
=
(
"Attempting to parse hotwords"
,
"Hotword list:"
)
def
filter
(
self
,
record
):
msg
=
record
.
getMessage
()
return
not
any
(
blocked
in
msg
for
blocked
in
self
.
_BLOCKED
)
def
setup_logging
(
worker_index
:
int
=
0
)
->
None
:
"""初始化日志:控制台 + 按天滚动的文件。
...
...
@@ -48,9 +62,9 @@ def setup_logging(worker_index: int = 0) -> None:
# 降低第三方库的冗余日志
logging
.
getLogger
(
"urllib3"
)
.
setLevel
(
logging
.
WARNING
)
logging
.
getLogger
(
"modelscope"
)
.
setLevel
(
logging
.
WARNING
)
# 屏蔽 funasr 热词解析的刷屏日志(
每次 generate 都会打印 INFO 级别的热词列表)
logging
.
getLogger
(
"funasr.models.seaco_paraformer"
)
.
setLevel
(
logging
.
WARNING
)
logging
.
getLogger
(
"funasr.models.contextual_paraformer"
)
.
setLevel
(
logging
.
WARNING
)
# 屏蔽 funasr 热词解析的刷屏日志(
funasr 用 logging.info 直接调 root logger,
# 无法按模块 logger 屏蔽,只能在 root logger 上加 filter 按消息内容过滤)
root
.
addFilter
(
_HotwordLogFilter
()
)
def
make_worker_id
(
worker_index
:
int
)
->
str
:
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment