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 4f6d32a9
authored
Sep 02, 2024
by
‘chizw’
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]脚本更新
1 parent
be842ea8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
136 additions
and
8 deletions
kafka_service/test01.py
utils/ali/test_03_car.py
utils/finetune.py
utils/finetune_temp.sh
utils/moss_former.py
utils/word-leven-zh-v1.0.4.py
kafka_service/test01.py
View file @
4f6d32a
...
...
@@ -80,7 +80,7 @@ def test_paraformer():
# 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_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", "东联")
...
...
utils/ali/test_03_car.py
View file @
4f6d32a
...
...
@@ -182,8 +182,8 @@ credentials = AccessKeyCredential(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'],
client
=
AcsClient
(
region_id
=
'cn-beijing'
,
credential
=
credentials
)
# fileUrl = 'https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/d15515d1-6ccb-4e58-9ebf-47d45677b298.mp3'
base_path
=
"D:/software/python/project/funasr_web/audios/
temp
/"
txt_path
=
"/audios/11111.txt"
base_path
=
"D:/software/python/project/funasr_web/audios/
830
/"
txt_path
=
"
D:/software/python/project/funasr_web
/audios/11111.txt"
with
open
(
txt_path
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
for
index
,
line
in
enumerate
(
file
,
1
):
print
(
f
"line==={line}"
)
...
...
utils/finetune.py
View file @
4f6d32a
...
...
@@ -173,6 +173,4 @@ list = [866,-430,867,870,871,872,873]
for
id
in
list
:
# voice_slicing(id)
pass
print
(
str
(
2270
/
1000
))
\ No newline at end of file
pass
\ No newline at end of file
utils/finetune_temp.sh
0 → 100644
View file @
4f6d32a
# Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
# MIT License (https://opensource.org/licenses/MIT)
workspace
=
$(
pwd
)
# which gpu to train or finetune
export
CUDA_VISIBLE_DEVICES
=
"0"
gpu_num
=
$(
echo
$CUDA_VISIBLE_DEVICES
| awk -F
","
'{print NF}'
)
# model_name from model_hub, or model_dir in local path
## option 1, download model automatically
model_name_or_model_dir
=
"D:/software/python/model/modelscope/hub/iic/paraformer-temp"
#model_name_or_model_dir="D:\dev\python\project\FunASR\examples\industrial_data_pretraining\paraformer\outputs829\1.0"
## option 2, download model by git
#local_path_root=${workspace}/modelscope_models
#mkdir -p ${local_path_root}/${model_name_or_model_dir}
#git clone https://www.modelscope.cn/${model_name_or_model_dir}.git ${local_path_root}/${model_name_or_model_dir}
#model_name_or_model_dir=${local_path_root}/${model_name_or_model_dir}
# data dir, which contains: train.json, val.json
data_dir
=
"D:/software/python/project/funasr_web/dataset/temp/train"
# exp output dir
current_time
=
$(
date
'+%Y-%m-%d %H:%M:%S'
)
output_dir
=
"D:/software/python/project/funasr_web/log/outputs829"
log_file
=
"
${
output_dir
}
/log.txt"
train_data
=
"
${
data_dir
}
/train.jsonl"
val_data
=
"
${
data_dir
}
/val.jsonl"
train_wav_scp
=
"
${
data_dir
}
/train_wav.scp"
train_wav_text
=
"
${
data_dir
}
/train_text.txt"
# generate train.jsonl and val_old.jsonl from wav.scp and text.txt
scp2jsonl
\
++scp_file_list
=
"[
${
train_wav_scp
}
,
${
train_wav_text
}
]"
\
++data_type_list
=
'["source", "target"]'
\
++jsonl_file_out
=
"
${
train_data
}
"
val_wav_scp
=
"
${
data_dir
}
/val_wav.scp"
val_wav_text
=
"
${
data_dir
}
/val_text.txt"
scp2jsonl
\
++scp_file_list
=
"[
${
val_wav_scp
}
,
${
val_wav_text
}
]"
\
++data_type_list
=
'["source", "target"]'
\
++jsonl_file_out
=
"
${
val_data
}
"
deepspeed_config
=
${
workspace
}
/../../ds_stage1.json
mkdir -p
${
output_dir
}
echo
"log_file:
${
log_file
}
"
DISTRIBUTED_ARGS
=
"
--nnodes
${
WORLD_SIZE
:-
1
}
\
--nproc_per_node
$gpu_num
\
--node_rank
${
RANK
:-
0
}
\
--master_addr
${
MASTER_ADDR
:-
127
.0.0.1
}
\
--master_port
${
MASTER_PORT
:-
26669
}
"
echo
$DISTRIBUTED_ARGS
dataset_type_val
=
"small"
batch_bins_val
=
2000
torchrun
$DISTRIBUTED_ARGS
\
../../../funasr/bin/train_ds.py
\
++model
=
"
${
model_name_or_model_dir
}
"
\
++train_data_set_list
=
"
${
train_data
}
"
\
++valid_data_set_list
=
"
${
val_data
}
"
\
++dataset
=
"AudioDataset"
\
++dataset_conf.index_ds
=
"IndexDSJsonl"
\
++dataset_conf.data_split_num
=
1
\
++dataset_conf.batch_sampler
=
"BatchSampler"
\
++dataset_conf.batch_size
=
1000
\
++dataset_conf.sort_size
=
1024
\
++dataset_conf.batch_type
=
"token"
\
++dataset_conf.num_workers
=
4
\
++dataset_conf.batch_bins
=
${
batch_bins_val
}
\
++dataset_conf.backend
=
"gloo"
\
++dataset_conf.dataset_type
=
${
dataset_type_val
}
\
++train_conf.max_epoch
=
100
\
++train_conf.log_interval
=
1
\
++train_conf.resume
=
true
\
++train_conf.validate_interval
=
2000
\
++train_conf.save_checkpoint_interval
=
2000
\
++train_conf.keep_nbest_models
=
10
\
++train_conf.avg_nbest_model
=
5
\
++train_conf.use_deepspeed
=
false
\
++train_conf.deepspeed_config
=
${
deepspeed_config
}
\
++train_conf.batch_bins
=
${
batch_bins_val
}
\
++train_conf.dataset_type
=
${
dataset_type_val
}
\
++train_conf.use_fp16
=
true
\
++train_conf.avg_keep_nbest_models_type
=
"acc"
\
++train_conf.accum_grad
=
1
\
++train_conf.grad_clip
=
10.0
\
++optim_conf.lr
=
0.0005
\
++output_dir
=
"
${
output_dir
}
"
\
++dataset_type
=
${
dataset_type_val
}
\
++batch_bins
=
${
batch_bins_val
}
&>
${
log_file
}
utils/moss_former.py
0 → 100644
View file @
4f6d32a
import
onnx
import
onnxruntime
as
ort
import
numpy
as
np
import
soundfile
as
sf
def
save_result
(
est_source
):
result
=
[]
for
ns
in
range
(
2
):
signal
=
est_source
[
0
,
:,
ns
]
signal
=
signal
/
np
.
abs
(
signal
)
.
max
()
*
0.5
signal
=
signal
[
np
.
newaxis
,
:]
# convert numpy array to pcm
output
=
(
signal
*
32768
)
.
astype
(
np
.
int16
)
.
tobytes
()
result
.
append
(
output
)
save_file
=
f
'output_spk{ns}.wav'
sf
.
write
(
save_file
,
np
.
frombuffer
(
output
,
dtype
=
np
.
int16
),
16000
)
onnx_model_path
=
'simple_model.onnx'
onnx_model
=
onnx
.
load
(
onnx_model_path
)
onnx
.
checker
.
check_model
(
onnx_model
)
ort_session
=
ort
.
InferenceSession
(
onnx_model_path
)
input_data
,
sr
=
sf
.
read
(
'mix_speech1_16000.wav'
)
if
sr
!=
16000
:
raise
'Only supports 16000 Hz'
if
input_data
.
ndim
>
1
:
raise
'Only supports 1 channel'
input_data
=
np
.
expand_dims
(
input_data
,
axis
=
0
)
.
astype
(
np
.
float32
)
input_name
=
ort_session
.
get_inputs
()[
0
]
.
name
outputs
=
ort_session
.
run
(
None
,
{
input_name
:
input_data
})
print
(
'output_data:'
,
outputs
)
output_data
=
outputs
[
0
]
save_result
(
output_data
)
\ No newline at end of file
utils/word-leven-zh-v1.0.4.py
View file @
4f6d32a
...
...
@@ -64,9 +64,9 @@ def dealcompare(file1_path, file2_path):
filename
=
'82874'
# 人工标注文件:
personfile
=
f
'
C:/Users/chizw/Desktop/新建文本文档
.txt'
personfile
=
f
'
D:/software/python/project/funasr_web/audios/leven/correct
.txt'
# 训练后文件:
trainfile
=
f
'
C:/Users/chizw/Desktop/output
.txt'
trainfile
=
f
'
D:/software/python/project/funasr_web/audios/leven/output3
.txt'
dealcompare
(
personfile
,
trainfile
)
print
(
'================================end==============================='
)
...
...
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