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 ffef9179
authored
Jan 15, 2025
by
chenxx
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
http://192.168.3.233:8090/eshiled-new/funasr_web
2 parents
6ca1e59e
9f7e5e4e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
22 deletions
funasr_service.py
kafka_service/funasr_consumer.py
kafka_service/test01.py
mysql_service/funasr_db.py
utils/finetune.py
funasr_service.py
View file @
ffef917
...
@@ -183,7 +183,8 @@ def deal_worker(task_id: str):
...
@@ -183,7 +183,8 @@ def deal_worker(task_id: str):
log
.
info
(
f
"Worker {task_id} is running... url:{url}"
)
log
.
info
(
f
"Worker {task_id} is running... url:{url}"
)
consuming_start_time
=
time
.
perf_counter
()
consuming_start_time
=
time
.
perf_counter
()
# 解析音频
# 解析音频
output_res
=
FunasrService
(
url
)
.
transform
()
funasr_instance
=
FunasrService
(
url
)
output_res
=
funasr_instance
.
transform
()
if
len
(
output_res
)
<
1
:
if
len
(
output_res
)
<
1
:
log
.
info
(
"output_res:
%
s"
%
output_res
)
log
.
info
(
"output_res:
%
s"
%
output_res
)
funasr_db
.
update_ali_asr_model_res
(
task_id
,
str
(
output_res
),
0
)
funasr_db
.
update_ali_asr_model_res
(
task_id
,
str
(
output_res
),
0
)
...
@@ -200,10 +201,13 @@ def deal_worker(task_id: str):
...
@@ -200,10 +201,13 @@ def deal_worker(task_id: str):
# 强制进行垃圾回收
# 强制进行垃圾回收
gc
.
collect
()
gc
.
collect
()
except
Exception
as
e
:
except
Exception
as
e
:
log
.
error
(
f
"Worker error:{traceback.format_exc()}"
)
log
.
error
(
f
"
task_id:{task_id}
Worker error:{traceback.format_exc()}"
)
funasr_db
.
update_ali_asr_model_res_fail
(
task_id
,
str
(
e
),
traceback
.
format_exc
())
funasr_db
.
update_ali_asr_model_res_fail
(
task_id
,
str
(
e
),
traceback
.
format_exc
())
# funasr_producer.send_task_id(task_id)
# funasr_producer.send_task_id(task_id)
return
return
finally
:
funasr_instance
=
None
gc
.
collect
()
def
fine_grained_transform_output
(
sentence_info
):
def
fine_grained_transform_output
(
sentence_info
):
...
...
kafka_service/funasr_consumer.py
View file @
ffef917
import
json
import
multiprocessing
import
multiprocessing
import
threading
import
threading
import
time
import
traceback
import
traceback
import
funasr_service
import
funasr_service
from
kafka
import
KafkaConsumer
from
kafka
import
KafkaConsumer
...
@@ -9,8 +8,6 @@ from log.logger import log
...
@@ -9,8 +8,6 @@ from log.logger import log
from
config.config
import
ConfigInfo
from
config.config
import
ConfigInfo
from
concurrent.futures
import
ThreadPoolExecutor
from
concurrent.futures
import
ThreadPoolExecutor
from
kafka.structs
import
TopicPartition
from
kafka.structs
import
TopicPartition
from
tqdm
import
tqdm
import
numpy
as
np
import
gc
import
gc
from
concurrent.futures
import
ProcessPoolExecutor
,
as_completed
,
wait
,
FIRST_COMPLETED
from
concurrent.futures
import
ProcessPoolExecutor
,
as_completed
,
wait
,
FIRST_COMPLETED
...
...
kafka_service/test01.py
View file @
ffef917
...
@@ -175,5 +175,6 @@ def select_extract_data():
...
@@ -175,5 +175,6 @@ def select_extract_data():
# run("https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_172075478615417207538825792.mp3", "东联")
# run("https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_172075478615417207538825792.mp3", "东联")
# run("https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_172119302897717211886442290.mp3", "李钰达")
# run("https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_172119302897717211886442290.mp3", "李钰达")
# run("https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_17205900068901720588971648.mp3", "张东华")
# run("https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_17205900068901720588971648.mp3", "张东华")
run
(
"https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/车辆知识_保险基础知识培训-视频.mp3"
,
"保险基础知识培训"
)
select_extract_data
()
\ No newline at end of file
\ No newline at end of file
# select_extract_data()
\ No newline at end of file
\ No newline at end of file
mysql_service/funasr_db.py
View file @
ffef917
from
mysql_service
import
MysqlHelper
from
config
import
DbConect
from
config.config
import
ConfigInfo
from
config.config
import
ConfigInfo
from
mysql_service
import
mysql_utils
from
mysql_service.mysql_pool
import
ConnPool
from
mysql_service.mysql_pool
import
ConnPool
# db = MysqlHelper.MysqlHelper(
# db = MysqlHelper.MysqlHelper(
...
@@ -20,6 +18,8 @@ pool = ConnPool(
...
@@ -20,6 +18,8 @@ pool = ConnPool(
**
config
**
config
)
)
EXCEPTION_LIMIT
=
5
def
insert_ali_asr_model_res
(
task_id
:
str
,
url
:
str
):
def
insert_ali_asr_model_res
(
task_id
:
str
,
url
:
str
):
insert_sql
=
(
insert_sql
=
(
...
@@ -37,18 +37,19 @@ def update_ali_asr_model_res(task_id: str, json_output: str, execute_time: int):
...
@@ -37,18 +37,19 @@ def update_ali_asr_model_res(task_id: str, json_output: str, execute_time: int):
def
update_ali_asr_model_res_fail
(
task_id
:
str
,
exception_msg
:
str
,
exception
:
str
):
def
update_ali_asr_model_res_fail
(
task_id
:
str
,
exception_msg
:
str
,
exception
:
str
):
update_sql
=
(
update_sql
=
(
"update ali_asr_model_res t set t.task_status = 2, t.exception_msg =
%
s, t.exception_log =
%
s, "
"update ali_asr_model_res t set t.task_status = case when exception_limit >=
%
s then 2 else 0 end, "
"t.exception_msg =
%
s, t.exception_log =
%
s, "
"exception_limit = exception_limit + 1 "
"exception_limit = exception_limit + 1 "
"where t.task_id =
%
s and del_flag = 0;"
)
"where t.task_id =
%
s and del_flag = 0;"
)
return
pool
.
update_one
(
update_sql
,
(
exception_msg
,
exception
,
task_id
,))
return
pool
.
update_one
(
update_sql
,
(
EXCEPTION_LIMIT
,
exception_msg
,
exception
,
task_id
,))
def
update_ali_asr_model_res_skip
(
task_id
:
str
):
def
update_ali_asr_model_res_skip
(
task_id
:
str
):
update_sql
=
(
update_sql
=
(
"update ali_asr_model_res t set t.task_status =
2
,"
"update ali_asr_model_res t set t.task_status =
case when exception_limit >=
%
s then 2 else 0 end
,"
"exception_limit = exception_limit + 1 "
"exception_limit = exception_limit + 1 "
"where t.task_id =
%
s and del_flag = 0;"
)
"where t.task_id =
%
s and del_flag = 0;"
)
return
pool
.
update_one
(
update_sql
,
(
task_id
,))
return
pool
.
update_one
(
update_sql
,
(
EXCEPTION_LIMIT
,
task_id
,))
def
select_ali_asr_model_res
(
task_id
:
str
):
def
select_ali_asr_model_res
(
task_id
:
str
):
...
@@ -56,17 +57,17 @@ def select_ali_asr_model_res(task_id: str):
...
@@ -56,17 +57,17 @@ def select_ali_asr_model_res(task_id: str):
"select id,task_id,file_url,task_status,output_data,exception_msg"
"select id,task_id,file_url,task_status,output_data,exception_msg"
" from ali_asr_model_res aamr"
" from ali_asr_model_res aamr"
" where del_flag = 0 and "
" where del_flag = 0 and "
" task_id =
%
s and exception_limit <
3
"
" task_id =
%
s and exception_limit <
%
s
"
" order by created_time desc;"
" order by created_time desc;"
)
)
return
pool
.
select_all
(
select_sql
,
(
task_id
,))
return
pool
.
select_all
(
select_sql
,
(
task_id
,
EXCEPTION_LIMIT
))
def
select_ali_asr_model_wait
():
def
select_ali_asr_model_wait
():
select_sql
=
(
select_sql
=
(
"select id,task_id,file_url,task_status,output_data from ali_asr_model_res aamr where aamr.del_flag = 0 and "
"select id,task_id,file_url,task_status,output_data from ali_asr_model_res aamr where aamr.del_flag = 0 and "
"aamr.output_data is null and aamr.task_status !=
%
s and exception_limit <
3
;"
)
"aamr.output_data is null and aamr.task_status !=
%
s and exception_limit <
%
s
;"
)
return
pool
.
select_all
(
select_sql
,
1
)
return
pool
.
select_all
(
select_sql
,
(
1
,
EXCEPTION_LIMIT
)
)
def
select_process_fail_task
(
process_name
:
str
):
def
select_process_fail_task
(
process_name
:
str
):
...
@@ -96,11 +97,11 @@ def select_process_all_end():
...
@@ -96,11 +97,11 @@ def select_process_all_end():
def
select_time_out_task
():
def
select_time_out_task
():
sql
=
(
sql
=
(
"select id,task_id,file_url,task_status from ali_asr_model_res aamr where aamr.del_flag = 0 "
"select id,task_id,file_url,task_status from ali_asr_model_res aamr where aamr.del_flag = 0 "
"and aamr.output_data is null and exception_limit <
3
"
"and aamr.output_data is null and exception_limit <
%
s
"
# "and aamr.execute_process_name is not null "
# "and aamr.execute_process_name is not null "
"and aamr.updated_time < TIMESTAMPADD(HOUR, -
%
s, NOW());"
"and aamr.updated_time < TIMESTAMPADD(HOUR, -
%
s, NOW());"
)
)
return
pool
.
select_all
(
sql
,
(
2
))
return
pool
.
select_all
(
sql
,
(
EXCEPTION_LIMIT
,
2
))
def
select_voice_data
(
id
):
def
select_voice_data
(
id
):
...
...
utils/finetune.py
View file @
ffef917
...
@@ -298,7 +298,7 @@ def upload_files(name, file_path):
...
@@ -298,7 +298,7 @@ def upload_files(name, file_path):
# crop_audio_by_rule(500 * 1000 * 3600)
# crop_audio_by_rule(500 * 1000 * 3600)
def
format_audio_and_text
():
def
format_audio_and_text
():
append_sys_param
(
"env"
,
"
release
"
)
append_sys_param
(
"env"
,
"
dev
"
)
import
funasr_service
import
funasr_service
from
mysql_service
import
funasr_db
from
mysql_service
import
funasr_db
audio_path
=
f
'D:/software/python/project/funasr_web/audios/train_audio/down_audio/'
audio_path
=
f
'D:/software/python/project/funasr_web/audios/train_audio/down_audio/'
...
@@ -382,4 +382,4 @@ def down_file_upload_release(table_name):
...
@@ -382,4 +382,4 @@ def down_file_upload_release(table_name):
print
(
sql
)
print
(
sql
)
upload_file
(
"1_1120_赛力斯、平安智驾项目对接会议.m4a"
,
"D:
\\
software
\\
python
\\
project
\\
funasr_web
\\
log
\\
1_1120_赛力斯、平安智驾项目对接会议.m4a
"
)
upload_file
(
"1_1120_赛力斯、平安智驾项目对接会议.m4a"
,
"D:
\\
software
\\
python
\\
project
\\
funasr_web
\\
dataset
\\
20241205152115-车辆知识_保险基础知识培训-视频-1 - 副本.mp3
"
)
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