Views
No views yet
若用【个】表示【的】,那么【有个人】,究竟是【有一个人】,还是【有的人】呢? 因此本数据集用【介】代替【个】。
若用【只】表示【这】,那么【这只猫】、【这只车】,便会写成【只只猫】、【只只车】,看起来非常怪异,因此本数据集用繁异字【祇】表示【这】之意,其他情况同普通话。| 数据子集 | CER(%) |
|---|---|
| 验证集 | 12.865 |
| 测试集 | 12.254 |
安装依赖:
pip install -r requirements.txtfrom transformers import pipeline
device = "cuda:0" if torch.cuda.is_available() else "cpu"
# 创建识别管道
pipe = pipeline(
"automatic-speech-recognition",
model="panlr/whisper-finetune-teochew",
device=device
)
# 识别音频
result = pipe("example.wav")
print(result["text"])import torch
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
# 设置设备
device = "cuda:0" if torch.cuda.is_available() else "cpu"
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
# 加载模型
model = AutoModelForSpeechSeq2Seq.from_pretrained(
"panlr/whisper-finetune-teochew",
torch_dtype=torch_dtype,
low_cpu_mem_usage=True,
use_safetensors=True
)
model.to(device)
# 加载处理器
processor = AutoProcessor.from_pretrained("panlr/whisper-finetune-teochew")
# 创建推理管道
pipe = pipeline(
"automatic-speech-recognition",
model=model,
tokenizer=processor.tokenizer,
feature_extractor=processor.feature_extractor,
torch_dtype=torch_dtype,
device=device,
)
# 执行识别
result = pipe("example.wav")
print(result["text"]) python inference.py audio.wav
python inference.py audio.wav --model panlr/whisper-finetune-teochew
python inference.py audio.wav --cpu
python inference.py audio1.wav audio2.wav audio3.wav --output result.txt