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 3505a1bd
authored
Mar 15, 2024
by
‘chizw’
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
音频转移接口
1 parent
bd2403c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
main.py
test01.py
main.py
View file @
3505a1b
import
argparse
import
argparse
import
traceback
from
datetime
import
timedelta
from
datetime
import
timedelta
import
json
import
json
import
logging
import
logging
...
@@ -207,13 +208,15 @@ def deal_worker(url: str, task_id: str):
...
@@ -207,13 +208,15 @@ def deal_worker(url: str, task_id: str):
"""
"""
try
:
try
:
logger
.
info
(
f
"Worker {task_id} is running..."
)
logger
.
info
(
f
"Worker {task_id} is running..."
)
insertSql
=
(
f
"INSERT INTO dj_smartcarlife.ali_asr_model_res (task_id,file_url,task_status) VALUES ('{task_id}','{url}',0);"
)
res
=
db
.
execute_modify
(
insertSql
)
consuming_start_time
=
time
.
perf_counter
()
consuming_start_time
=
time
.
perf_counter
()
# 解析音频
# 解析音频
res
=
FunasrService
(
url
)
.
transform
()
res
=
FunasrService
(
url
)
.
transform
()
logger
.
info
(
"res:
%
s"
%
str
(
res
[
0
][
"sentence_info"
]))
logger
.
info
(
"res:
%
s"
%
res
)
if
len
(
res
)
<
1
:
updateSql
=
(
f
"update ali_asr_model_res t set t.output_data = '{res}',t.task_status = 1 where t.task_id = '{task_id}';"
)
db
.
execute_modify
(
updateSql
)
return
output
=
[]
output
=
[]
content
=
""
content
=
""
spk
=
0
spk
=
0
...
@@ -245,6 +248,7 @@ def deal_worker(url: str, task_id: str):
...
@@ -245,6 +248,7 @@ def deal_worker(url: str, task_id: str):
updateSql
=
(
f
"update ali_asr_model_res t set t.task_status = 2 where t.task_id = '{task_id}';"
)
updateSql
=
(
f
"update ali_asr_model_res t set t.task_status = 2 where t.task_id = '{task_id}';"
)
db
.
execute_modify
(
updateSql
)
db
.
execute_modify
(
updateSql
)
logger
.
error
(
f
"Worker error:{e}"
)
logger
.
error
(
f
"Worker error:{e}"
)
traceback
.
print_exc
()
return
{
"Worker error"
:
str
(
e
)}
return
{
"Worker error"
:
str
(
e
)}
...
@@ -256,7 +260,11 @@ class UrlParam(BaseModel):
...
@@ -256,7 +260,11 @@ class UrlParam(BaseModel):
async
def
create_url
(
param
:
UrlParam
):
async
def
create_url
(
param
:
UrlParam
):
try
:
try
:
task_id
=
uuid
.
uuid1
()
task_id
=
uuid
.
uuid1
()
process
=
multiprocessing
.
Process
(
target
=
deal_worker
,
args
=
(
param
.
url
,
task_id
,))
url
=
param
.
url
insertSql
=
(
f
"INSERT INTO dj_smartcarlife.ali_asr_model_res (task_id,file_url,task_status) VALUES ('{task_id}','{url}',0);"
)
res
=
db
.
execute_modify
(
insertSql
)
process
=
multiprocessing
.
Process
(
target
=
deal_worker
,
args
=
(
url
,
task_id
,))
logger
.
info
(
f
"process:{process}"
)
logger
.
info
(
f
"process:{process}"
)
process
.
start
()
process
.
start
()
response
=
BaseResponse
(
response
=
BaseResponse
(
...
@@ -268,6 +276,7 @@ async def create_url(param: UrlParam):
...
@@ -268,6 +276,7 @@ async def create_url(param: UrlParam):
return
response
return
response
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
f
"error:{e}"
)
logger
.
error
(
f
"error:{e}"
)
traceback
.
print_exc
()
return
{
"error"
:
str
(
e
)}
return
{
"error"
:
str
(
e
)}
...
...
test01.py
View file @
3505a1b
...
@@ -23,7 +23,7 @@ consuming_start_time = time.perf_counter()
...
@@ -23,7 +23,7 @@ consuming_start_time = time.perf_counter()
# res = model.generate(input="asr_example.wav", batch_size_s=300, hotword="魔搭")
# 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="123456.wav", batch_size_s=300, hotword="魔搭")
res
=
model
.
generate
(
res
=
model
.
generate
(
input
=
"
北京店1-2024-02-29_14.58.11.MP
3"
,
input
=
"
www.mp
3"
,
batch_size_s
=
300
,
batch_size_s
=
300
,
hotword
=
"问界 80
\n
电瓶 100
\n
保修 100
\n
问界店 100
\n
M7
\n
M5
\n
M9"
,
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