Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
funasr_web
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 7148f3cf
authored
Mar 22, 2024
by
‘chizw’
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]进程池优化
1 parent
e1421580
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
funasr_service.py
kafka_service/funasr_consumer.py
test01.py
funasr_service.py
View file @
7148f3c
...
...
@@ -65,8 +65,8 @@ class model_output():
def
handle_process
(
message
:
str
):
try
:
log
.
info
(
f
"
""handle_process process name:{multiprocessing.current_process()},thread name:{threading.current_thread().name},
Received task_id: {message}""
"
)
f
"
handle_process process name:{multiprocessing.current_process()},thread name:{threading.current_thread().name},"
f
"Received task_id: {message}
"
)
# 处理逻辑
start_time
=
time
.
time
()
task_id
=
json
.
loads
(
message
)[
"task_id"
]
...
...
kafka_service/funasr_consumer.py
View file @
7148f3c
...
...
@@ -109,7 +109,7 @@ def consume_kafka():
log
.
info
(
f
"启动consume_kafka Thread name:{threading.current_thread().name}"
)
# 消费消息并进行逻辑处理
try
:
process_pool
=
multiprocessing
.
Pool
(
processes
=
2
)
process_pool
=
multiprocessing
.
Pool
(
processes
=
3
)
for
message
in
consumer_new
:
if
message
is
None
:
continue
...
...
@@ -118,7 +118,7 @@ def consume_kafka():
# funasr_service.handle_process(str(message.value.decode('utf-8')))
process_pool
.
apply_async
(
funasr_service
.
handle_process
,
((
str
(
message
.
value
.
decode
(
'utf-8'
))),))
# process = multiprocessing.Process(target=funasr_service.handle_process, args=((str(message.value.decode('utf-8'))),),)
log
.
info
(
f
"process:{process_pool}"
)
log
.
info
(
f
"process
_pool
:{process_pool}"
)
# process.start()
print
(
"task handle"
)
# process_pool.close()
...
...
test01.py
View file @
7148f3c
...
...
@@ -25,7 +25,7 @@ consuming_start_time = time.perf_counter()
# res = model.generate(input="asr_example.wav", batch_size_s=300, hotword="魔搭")
# res = model.generate(input="123456.wav", batch_size_s=300, hotword="魔搭")
res
=
model
.
generate
(
input
=
"
www
.mp3"
,
input
=
"
7wyqx-pgxhv
.mp3"
,
batch_size_s
=
300
,
hotword
=
"问界 80
\n
电瓶 100
\n
保修 100
\n
问界店 100
\n
M7
\n
M5
\n
M9"
,
)
...
...
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