🚀 潮汕語Whisper Medium模型
本模型是Whisper medium模型的微調版本,用於識別潮汕話(潮州話),這是一種在中國南方使用的閩南語系語言。該模型能夠有效助力潮汕話的語音識別場景,為潮汕話相關的語音處理提供了有力支持。
🚀 快速開始
示例代碼
以下腳本可用於下載模型,並使用Gradio啟動一個運行該模型的演示:
import torch
import torchaudio
from transformers import WhisperProcessor, WhisperForConditionalGeneration
import gradio as gr
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
WHISPER_SAMPLE_RATE = 16000
processor = WhisperProcessor.from_pretrained("openai/whisper-medium")
model = WhisperForConditionalGeneration.from_pretrained(
"efficient-nlp/teochew-whisper-medium"
).to(DEVICE)
def preprocess_audio(audio_path: str) -> torch.Tensor:
audio, sample_rate = torchaudio.load(audio_path)
if sample_rate != WHISPER_SAMPLE_RATE:
resampler = torchaudio.transforms.Resample(
orig_freq=sample_rate, new_freq=WHISPER_SAMPLE_RATE
)
audio = resampler(audio)
if audio.shape[0] > 1:
audio = torch.mean(audio, dim=0)
return audio.squeeze()
def transcribe(audio_path: str) -> str:
audio_input = preprocess_audio(audio_path)
input_features = processor(
audio_input,
sampling_rate=WHISPER_SAMPLE_RATE,
return_tensors="pt",
language="Chinese",
).input_features.to(DEVICE)
predicted_ids = model.generate(input_features)
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
return transcription
iface = gr.Interface(
fn=transcribe,
inputs=gr.Audio(type="filepath"),
outputs="text",
title="Teochew Speech Recognition",
)
iface.launch()
📚 詳細文檔
關於該模型的訓練詳細文檔,請參考此視頻:https://www.youtube.com/watch?v=JH_78KmP4Zk
🔧 技術細節
訓練數據
該模型在約35小時的潮汕語電影、電視劇和喜劇音頻數據上進行了微調。
評估指標
在我們的私有測試集上,我們獲得了以下單詞錯誤率(WER)指標:
已知侷限性
該模型是在短音頻片段上進行訓練的,對於超過10秒的音頻可能處理效果不佳。
📄 許可證
本項目採用MIT許可證。