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 8217ea97
authored
Aug 22, 2024
by
‘chizw’
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]配置更改
1 parent
8e0fecbd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
11 deletions
kafka_service/test01.py
utils/finetune.py
kafka_service/test01.py
View file @
8217ea9
...
@@ -3,6 +3,8 @@ from kafka import KafkaConsumer
...
@@ -3,6 +3,8 @@ from kafka import KafkaConsumer
import
funasr_service
import
funasr_service
from
mysql_service
import
funasr_db
from
mysql_service
import
funasr_db
from
funasr
import
AutoModel
from
funasr
import
AutoModel
from
datetime
import
datetime
import
os
# 创建Kafka消费者
# 创建Kafka消费者
# consumer = KafkaConsumer(
# consumer = KafkaConsumer(
...
@@ -44,26 +46,42 @@ def insert_run():
...
@@ -44,26 +46,42 @@ def insert_run():
funasr_service
.
deal_worker
(
task_id
)
funasr_service
.
deal_worker
(
task_id
)
def
run
(
url
):
def
run
(
url
,
name
=
None
):
now
=
datetime
.
now
()
# 格式化时间
formatted_now
=
now
.
strftime
(
'
%
Y-
%
m-
%
d_
%
H-
%
M-
%
S'
)
if
url
is
None
:
if
url
is
None
:
url
=
'C:
\\
Users
\\
chizw
\\
Desktop
\\
zhanggy202407100001.wav'
url
=
'C:
\\
Users
\\
chizw
\\
Desktop
\\
zhanggy202407100001.wav'
res
=
funasr_service
.
FunasrService
(
url
)
.
transform
()
res
=
funasr_service
.
FunasrService
(
url
)
.
transform
()
# print(f"res:{str(res)}")
# print(f"res:{str(res)}")
print
(
f
"url:{str(url)}"
)
print
(
f
"url:{str(url)}"
)
funasr_service
.
test_comparison_transform_output
(
res
[
0
][
"sentence_info"
])
if
name
is
None
:
basename
,
extension
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
url
))
name
=
basename
output
=
funasr_service
.
test_comparison_transform_output
(
res
[
0
][
"sentence_info"
])
for
text
in
output
:
with
open
(
f
'../log/{name}_{formatted_now}.txt'
,
'a'
)
as
file
:
file
.
write
(
text
)
# print(f"sentence_info:{funasr_service.fine_grained_transform_output(res[0]['sentence_info'])}")
# print(f"sentence_info:{funasr_service.fine_grained_transform_output(res[0]['sentence_info'])}")
def
test_paraformer
():
def
test_paraformer
():
model
=
AutoModel
(
model
=
AutoModel
(
model
=
"dengcunqin/speech_seaco_paraformer_large_asr_nat-zh-cantonese-en-16k-common-vocab11666-pytorch"
,
model
=
"dengcunqin/speech_seaco_paraformer_large_asr_nat-zh-cantonese-en-16k-common-vocab11666-pytorch"
,
model_revision
=
"master"
model_revision
=
"master"
)
)
res
=
model
.
generate
(
res
=
model
.
generate
(
input
=
"https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_17161083134331716107368353.mp3"
,
input
=
"https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_17161083134331716107368353.mp3"
,
hotword
=
wav_root_url
+
"example/hotword.txt"
,
hotword
=
wav_root_url
+
"example/hotword.txt"
,
)
)
print
(
res
)
print
(
res
)
funasr_service
.
run
()
run
(
"https://smartcard-1253080096.cos.ap-guangzhou.myqcloud.com/audio/806599C6309C_1710219356_806599C6309C-1710219356.MP3"
,
"旧北京"
)
run
(
"https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_17205808870541720579482995.mp3"
,
"李丽"
)
run
(
"https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_17205827687271720580657722.mp3"
,
"江门嘉钡"
)
run
(
"https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/merged_17212740566661721272782874.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_17212740566661721272782874.mp3"
,
"李钰达"
)
utils/finetune.py
View file @
8217ea9
...
@@ -33,7 +33,6 @@ def upload_file(fileName, filePath):
...
@@ -33,7 +33,6 @@ def upload_file(fileName, filePath):
def
download_audio
(
url
,
output_path
):
def
download_audio
(
url
,
output_path
):
"""Download audios file from URL."""
response
=
requests
.
get
(
url
)
response
=
requests
.
get
(
url
)
with
open
(
output_path
,
'wb'
)
as
f
:
with
open
(
output_path
,
'wb'
)
as
f
:
f
.
write
(
response
.
content
)
f
.
write
(
response
.
content
)
...
@@ -47,16 +46,12 @@ def append_to_file(filePath, content, encoding_format='gbk'):
...
@@ -47,16 +46,12 @@ def append_to_file(filePath, content, encoding_format='gbk'):
def
remove_punctuation
(
input_string
):
def
remove_punctuation
(
input_string
):
# Make a translator object to remove all punctuation
translator
=
str
.
maketrans
(
''
,
''
,
string
.
punctuation
)
translator
=
str
.
maketrans
(
''
,
''
,
string
.
punctuation
)
# Use the translator object to remove punctuation from the input string
no_punct
=
input_string
.
translate
(
translator
)
no_punct
=
input_string
.
translate
(
translator
)
return
no_punct
return
no_punct
def
remove_punctuation_re
(
input_string
):
def
remove_punctuation_re
(
input_string
):
# Use regular expression to replace all punctuation with an empty string
no_punct
=
re
.
sub
(
r'[^\w\s]'
,
''
,
input_string
)
no_punct
=
re
.
sub
(
r'[^\w\s]'
,
''
,
input_string
)
return
no_punct
return
no_punct
...
@@ -76,7 +71,6 @@ output_val_wav_path = f"{train_path}/val_wav.scp"
...
@@ -76,7 +71,6 @@ output_val_wav_path = f"{train_path}/val_wav.scp"
def
update_dataset_paths
(
version
):
def
update_dataset_paths
(
version
):
global
base_subfix_path
,
base_output_directory
,
train_path
,
local_train_path
,
output_train_text_path
,
\
global
base_subfix_path
,
base_output_directory
,
train_path
,
local_train_path
,
output_train_text_path
,
\
output_train_wav_path
,
output_val_text_path
,
output_val_wav_path
output_train_wav_path
,
output_val_text_path
,
output_val_wav_path
# 更新所有与 dataset_version 相关的路径
base_subfix_path
=
f
"dataset/{version}"
base_subfix_path
=
f
"dataset/{version}"
base_output_directory
=
f
'D:/software/python/project/funasr_web/dataset/{version}/'
base_output_directory
=
f
'D:/software/python/project/funasr_web/dataset/{version}/'
train_path
=
f
'D:/software/python/project/funasr_web/dataset/{version}/train'
train_path
=
f
'D:/software/python/project/funasr_web/dataset/{version}/train'
...
...
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