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 a68661a5
authored
Sep 10, 2024
by
‘chizw’
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]脚本更新
1 parent
3abe62fd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
125 additions
and
17 deletions
config/config_release.py
funasr_train_test/test002.py
kafka_service/test01.py
mysql_service/funasr_db.py
utils/ali/test_03_car.py
utils/request.py
config/config_release.py
View file @
a68661a
...
...
@@ -12,7 +12,8 @@ class Config:
password
=
'rAzjFsfp'
database
=
'dj_smartcarlife'
# Kafka consumer配置
kafka_consumer_bootstrap_servers
=
'newbiz.kafka.zk.glsx.com:9094'
# kafka_consumer_bootstrap_servers = 'newbiz.kafka.zk.glsx.com:9094'
kafka_consumer_bootstrap_servers
=
'192.168.5.12:9094'
kafka_consumer_group_id
=
'funasr_release'
kafka_consumer_auto_offset_reset
=
'earliest'
kafka_consumer_analysis_topic
=
'funasr_analysis_topic'
...
...
funasr_train_test/test002.py
View file @
a68661a
# 版本要求 modelscope 升级至最新版本 funasr升级至最新版本
from
modelscope.pipelines
import
pipeline
sd_pipeline
=
pipeline
(
task
=
"speaker-diarization"
,
model
=
"damo/speech_eres2net-large_speaker-diarization_common"
,
model_revision
=
"v1.0.0"
,
)
input_wav
=
"https://modelscope.cn/api/v1/models/damo/speech_campplus_speaker-diarization_common/repo?Revision=master&FilePath=examples/2speakers_example.wav"
result
=
sd_pipeline
(
input_wav
)
print
(
result
)
# 如果有先验信息,输入实际的说话人数,会得到更准确的预测结果
result
=
sd_pipeline
(
input_wav
,
oracle_num
=
2
)
print
(
result
)
\ No newline at end of file
# # 版本要求 modelscope 升级至最新版本 funasr升级至最新版本
# from modelscope.pipelines import pipeline
#
# sd_pipeline = pipeline(
# task="speaker-diarization",
# model="damo/speech_eres2net-large_speaker-diarization_common",
# model_revision="v1.0.0",
# )
# input_wav = "https://modelscope.cn/api/v1/models/damo/speech_campplus_speaker-diarization_common/repo?Revision=master&FilePath=examples/2speakers_example.wav"
# result = sd_pipeline(input_wav)
# print(result)
# # 如果有先验信息,输入实际的说话人数,会得到更准确的预测结果
# result = sd_pipeline(input_wav, oracle_num=2)
# print(result)
from
mysql_service
import
funasr_db
from
utils
import
request
data
=
funasr_db
.
select_funasr_release_data
(
'2024-08-01'
,
'2024-09-01'
)
print
(
data
)
print
(
len
(
data
))
# for item in data:
# request.post_funasr_task(fileUrl=item["file_url"],env='dev')
with
open
(
f
'../log/map.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
file
:
for
item
in
data
:
file
.
write
(
"
%
s,
%
s
\n
"
%
(
item
[
"task_id"
],
item
[
"file_url"
]))
# request.post_funasr_task(fileUrl='https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/17258700437869947_17258694628871.mp3',env='dev')
kafka_service/test01.py
View file @
a68661a
...
...
@@ -77,6 +77,49 @@ def test_paraformer():
)
print
(
res
)
def
parse_file_to_dict
(
file_path
):
data_dict
=
{}
try
:
with
open
(
file_path
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
for
line
in
file
:
# 去除行尾的换行符
line
=
line
.
strip
()
# 使用逗号分隔键和值
parts
=
line
.
split
(
','
,
1
)
if
len
(
parts
)
==
2
:
key
,
value
=
parts
data_dict
[
key
.
strip
()]
=
value
.
strip
()
else
:
print
(
f
"警告: 行 '{line}' 未按逗号分隔,将跳过此行。"
)
except
FileNotFoundError
:
print
(
f
"错误: 文件 '{file_path}' 未找到。"
)
except
Exception
as
e
:
print
(
f
"错误: 读取文件时发生错误:{str(e)}"
)
return
data_dict
dict
=
parse_file_to_dict
(
"D:/software/python/project/funasr_web/log/all.txt"
)
def
read_files_in_directory
(
directory_path
):
# 遍历目录及子目录中的所有文件
for
root
,
dirs
,
files
in
os
.
walk
(
directory_path
):
for
file
in
files
:
file_path
=
os
.
path
.
join
(
root
,
file
)
try
:
# 尝试打开文件并读取内容
with
open
(
file_path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
content
=
f
.
read
()
file_name
,
extension
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
file_path
))
url
=
dict
.
get
(
file_name
)
if
url
is
None
:
print
(
f
"url不存在,file_name:{file_name}"
)
continue
funasr_db
.
insert_funasr_mock_data
(
file_name
,
url
,
content
)
except
UnicodeDecodeError
:
print
(
f
"警告: 文件 {file_path} 的编码不是 UTF-8,无法正确读取内容。"
)
except
Exception
as
e
:
print
(
f
"错误: 无法读取文件 {file_path},原因:{str(e)}"
)
# run("https://smartcard-1253080096.cos.ap-guangzhou.myqcloud.com/audio/806599C6309C_1710219356_806599C6309C-1710219356.MP3",
# "旧北京")
...
...
@@ -86,3 +129,6 @@ def test_paraformer():
# 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_17205900068901720588971648.mp3", "张东华")
read_files_in_directory
(
"D:/software/python/project/funasr_web/log/output/0910"
)
\ No newline at end of file
mysql_service/funasr_db.py
View file @
a68661a
...
...
@@ -96,6 +96,7 @@ def select_time_out_task():
)
return
pool
.
select_all
(
sql
,
(
30
))
def
select_voice_data
(
id
):
sql
=
(
"""select ibr.recording_url,icd.* from inspection_badge_recordings ibr
...
...
@@ -104,10 +105,23 @@ def select_voice_data(id):
)
return
pool
.
select_all
(
sql
,
(
id
))
def
select_funasr_output_data
(
id
):
sql
=
(
"""select * from inspection_badge_recordings ibr
left join ali_asr_model_res aamr on ibr.process_task_id = aamr.task_id and aamr.del_flag = 0
where ibr.deleted_flag = 'N' and ibr.id =
%
s;"""
)
return
pool
.
select_all
(
sql
,
(
id
))
\ No newline at end of file
return
pool
.
select_all
(
sql
,
(
id
))
def
select_funasr_release_data
(
start_time
,
end_time
,
):
sql
=
(
"""select aamr.task_id,aamr.file_url from ali_asr_model_res aamr where aamr.del_flag = 0 and aamr.created_time between
%
s and
%
s;"""
)
return
pool
.
select_all
(
sql
,
(
start_time
,
end_time
))
def
insert_funasr_mock_data
(
task_id
:
str
,
url
:
str
,
output_data
:
str
):
insert_sql
=
(
"INSERT INTO dj_smartcarlife.ali_asr_model_res (task_id, file_url, task_status, output_data, created_by) VALUES (
%
s,
%
s,
%
s,
%
s,
%
s);"
)
return
pool
.
insert_one
(
insert_sql
,
(
task_id
,
url
,
0
,
output_data
,
'mock'
,))
\ No newline at end of file
utils/ali/test_03_car.py
View file @
a68661a
...
...
@@ -205,4 +205,4 @@ def run_simple(fileUrl, name=None):
text_list
=
dealTaskResult
(
taskId
)
write_file
(
text_list
,
f
"{base_path}{name}.txt"
)
run_simple
(
"https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/1715688494984merged_17153238831671715320257955.mp3"
,
name
=
"test"
)
\ No newline at end of file
run_simple
(
"https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/1715688494984merged_17153238831671715320257955.mp3"
,
name
=
"test1"
)
\ No newline at end of file
utils/request.py
0 → 100644
View file @
a68661a
import
requests
import
json
def
post_funasr_task
(
fileUrl
,
env
=
'dev'
):
if
env
==
'test'
:
host
=
'192.168.3.211:7888'
elif
env
==
'beta'
:
host
=
'192.168.5.4:7888'
elif
env
==
'release'
:
host
=
'192.168.5.208:7888'
else
:
host
=
'192.168.3.211:7889'
url
=
f
"http://{host}/funasr/url"
payload
=
json
.
dumps
({
"url"
:
fileUrl
})
headers
=
{
'User-Agent'
:
'Apifox/1.0.0 (https://www.apifox.cn)'
,
'Content-Type'
:
'application/json'
,
'Accept'
:
'*/*'
,
'Host'
:
host
,
'Connection'
:
'keep-alive'
,
'Referer'
:
f
'http://{host}/funasr/url'
}
response
=
requests
.
request
(
"POST"
,
url
,
headers
=
headers
,
data
=
payload
)
print
(
response
.
text
)
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