Comments (1)
代码:
-- coding:utf-8 --
import argparse
import os
import traceback
from tqdm import tqdm
from funasr import AutoModel
model = AutoModel(
model = 'tools/asr/models/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch',
vad_model = 'tools/asr/models/speech_fsmn_vad_zh-cn-16k-common-pytorch',
punc_model = 'tools/asr/models/punc_ct-transformer_zh-cn-common-vocab272727-pytorch',
)
def only_asr(input_file):
try:
text = model.generate(input=input_file)[0]["text"]
except:
text = ''
print(traceback.format_exc())
return text
def execute_asr(input_folder, output_folder, model_size, language):
input_file_names = os.listdir(input_folder)
input_file_names.sort()
output = []
output_file_name = os.path.basename(input_folder)
for file_name in tqdm(input_file_names):
try:
file_path = os.path.join(input_folder, file_name)
text = model.generate(input=file_path)[0]["text"]
output.append(f"{file_path}|{output_file_name}|{language.upper()}|{text}")
except:
print(traceback.format_exc())
output_folder = output_folder or "output/asr_opt"
os.makedirs(output_folder, exist_ok=True)
output_file_path = os.path.abspath(f'{output_folder}/{output_file_name}.list')
with open(output_file_path, "w", encoding="utf-8") as f:
f.write("\n".join(output))
print(f"ASR 任务完成->标注文件路径: {output_file_path}\n")
return output_file_path
if name == 'main':
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--input_folder", type=str, required=True,
help="Path to the folder containing WAV files.")
parser.add_argument("-o", "--output_folder", type=str, required=True,
help="Output folder to store transcriptions.")
parser.add_argument("-s", "--model_size", type=str, default='large',
help="Model Size of FunASR is Large")
parser.add_argument("-l", "--language", type=str, default='zh', choices=['zh'],
help="Language of the audio files.")
parser.add_argument("-p", "--precision", type=str, default='float16', choices=['float16','float32'],
help="fp16 or fp32")#还没接入
cmd = parser.parse_args()
execute_asr(
input_folder = cmd.input_folder,
output_folder = cmd.output_folder,
model_size = cmd.model_size,
language = cmd.language,
)
from funasr.
Related Issues (20)
- 关于funasr 4.5 的docker包的问题改进 HOT 1
- 用funasr加载SenseVoiceSmall模型提示 not registered HOT 2
- handle_read_handshake error: websocketpp.transport:7 HOT 2
- python fastapi进行离线文件识别报错choose a window size 400 that is [2, 0]
- NCCL 多级多卡 训练 超时问题 HOT 1
- docker gpu启动离线推理服务,报错 failed PropagateTensorShapeOnNode with schema HOT 1
- FunASRWSClient_Offline 使用docker cpu4.5版本900多mb的wav文件会丢失大量识别文本
- 命令行执行错误 HOT 2
- 能不能自己打镜像?能否提供Dockerfile
- 为什么finetune speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch,验证集Update best acc: 0.0000
- runtime/csharp/ws-client/FunASRWSClient_Offline 项目不支持并发
- How to fine tune training without using GPU when using CPU version Docker images HOT 1
- 请问vad模型是否支持 实时音频流的语音端点检测? 为什么每次检测音频活动端点都是'value': [[0, 1180]]}]
- 微调sensevoice模型Update best acc: 0.0000
- 无法理解传入的参数,使用ASR HOT 2
- parformer大规模数据集预训练cpu内存持续增加的问题
- docker gpu1.1长文件时间戳偏移很大
- label_smoothing_loss target None
- GPU版本:[W shape_analysis.cpp:841] failed PropagateTensorShapeOnNode with schema HOT 1
- wrong submit. sorry for that.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from funasr.