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 d8eb77d8
authored
Mar 15, 2024
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加测试类
1 parent
3505a1bd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
test02.py
test02.py
0 → 100644
View file @
d8eb77d
import
time
from
funasr
import
AutoModel
# paraformer-zh is a multi-functional asr model
# use vad, punc, spk or not as you need
model
=
AutoModel
(
model
=
"paraformer-zh"
,
vad_model
=
"fsmn-vad"
,
punc_model
=
"ct-punc-c"
,
spk_model
=
"cam++"
,
# openai_model="Whisper-large-v3",
ncpu
=
8
,
)
def
write_text
(
text
):
with
open
(
"audio.txt"
,
"a+"
,
encoding
=
"utf8"
)
as
fw
:
fw
.
write
(
text
.
strip
())
fw
.
write
(
"
\n
"
)
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="北京店1-2024-02-29_14.58.11.MP3",
# batch_size_s=300,
# hotword="问界 80\n电瓶 100\n保修 100\n问界店 100\nM7\nM5\nM9",
# )
res
=
model
.
export
(
input
=
"北京店1-2024-02-29_14.58.11.MP3"
)
print
(
f
"res:{res}"
)
# sentence_info = res[0]["sentence_info"]
# print(f"res_sentence_info:{sentence_info}")
# # print(res[0]["sentence_info"])
# spk = 0
# total_time = 0
# content = ""
# for one in sentence_info:
# # print(one)
# # print(one["end"] - one["start"])
# # print(one["text"])
# # print(one["spk"])
# # print(f'{one["end"] - one["start"]}; {one["text"]}; {one["spk"]}')
# total_time = total_time + (one["end"] - one["start"])
# if spk == one["spk"]:
# content = content + one["text"]
# else:
# text = f'角色{spk + 1} : {content} -- 时长:{total_time}ms'
# print(text)
# write_text(text)
# total_time = 0
# content = one["text"]
# spk = one["spk"]
# if content is not None:
# text = f'角色{spk + 1} : {content} -- 时长:{total_time}ms'
# print(text)
# write_text(text)
# consuming_end_time = time.perf_counter()
# print(
# f"Function transform_file executed in {(consuming_end_time - consuming_start_time)} 秒"
# )
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