Edit model card

Wav2Vec2-Large-XLSR-53-Chinese-zh-CN-aishell1

Fine-tuned facebook/wav2vec2-large-xlsr-53 on Chinese using the AISHELL-1 dataset. When using this model, make sure that your speech input is sampled at 16kHz.

Usage

The model can be used directly (without a language model) as follows:

import torch
import librosa
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor

device = "cuda:0" if torch.cuda.is_available() else "cpu"

processor = Wav2Vec2Processor.from_pretrained(
    'qinyue/wav2vec2-large-xlsr-53-chinese-zn-cn-aishell1')
model = Wav2Vec2ForCTC.from_pretrained(
    'qinyue/wav2vec2-large-xlsr-53-chinese-zn-cn-aishell1').to(device)

filepath = 'test.wav'
audio, sr = librosa.load(filepath, sr=16000, mono=True)
inputs = processor(audio, sample_rate=16000, return_tensors="pt").to(device)
with torch.no_grad():
    logits = model(inputs.input_values,
                   attention_mask=inputs.attention_mask).logits
predicted_ids = torch.argmax(logits, dim=-1)
pred_str = processor.decode(predicted_ids[0])

print(pred_str)

Evaluation

wer_metric = load_metric("wer")

def compute_metrics(pred):
    pred_logits = pred.predictions
    pred_ids = np.argmax(pred_logits, axis=-1)

    pred.label_ids[pred.label_ids == -100] = processor.tokenizer.pad_token_id

    pred_str = processor.batch_decode(pred_ids, spaces_between_special_tokens=True)
    label_str = processor.batch_decode(pred.label_ids, group_tokens=False, spaces_between_special_tokens=True)

    wer = wer_metric.compute(predictions=pred_str, references=label_str)

    return {"wer": wer}

Results

Reference Prediction
据 伟 业 我 爱 我 家 市 场 研 究 院 测 算 据 北 业 我 爱 我 家 市 场 研 究 院 测 算
七 月 北 京 公 积 金 贷 款 成 交 量 提 升 了 百 分 之 五 七 月 北 京 公 积 金 贷 款 成 交 量 提 升 了 百 分 之 五
培 育 门 类 丰 富 层 次 齐 用 的 综 合 利 用 产 业 培 育 门 类 丰 富 层 资 集 业 的 综 合 利 用 产 业
我 们 迎 来 了 赶 超 发 达 国 家 的 难 得 机 遇 我 们 迎 来 了 赶 超 发 达 国 家 的 单 得 机 遇
坚 持 基 本 草 原 保 护 制 度 坚 持 基 本 草 员 保 护 制 度
强 化 水 生 生 态 修 复 和 建 设 强 化 水 生 生 态 修 复 和 建 设
温 州 两 男 子 为 争 女 人 驾 奔 驰 宝 马 街 头 四 次 对 撞 温 州 两 男 子 为 争 女 人 架 奔 驰 宝 马 接 头 四 次 对 重
她 表 示 应 该 是 吃 吃 饭 看 电 影 之 类 的 他 表 示 一 的 是 吃 吃 饭 看 电 影 之 理
加 强 畜 禽 遗 传 资 源 和 农 业 野 生 植 物 资 源 保 护 加 强 续 紧 遗 传 资 源 和 农 业 野 生 职 物 资 源 保 护
两 人 都 是 依 赖 电 话 沟 通 两 人 都 是 依 赖 电 话 沟 通

Test Result:

In the table below I report the Word Error Rate (WER) of the model on the AISHELL-1 test dataset.

Model WER WER-with-LM
qinyue/wav2vec2-large-xlsr-53-chinese-zn-cn-aishell1 7.04% 3.96%
Downloads last month
1
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Space using qinyue/wav2vec2-large-xlsr-53-chinese-zn-cn-aishell1 1

Evaluation results