Wav2vecbert2 Filledpause
モデル概要
モデル特徴
モデル能力
使用事例
🚀 フレーム単位の埋め込みポーズ分類モデル
このモデルは、埋め込みポーズ("eee"、"errm" など)の有無に基づいて、音声の個々の 20ms フレームを分類します。
🚀 クイックスタート
このモデルは、音声の 20ms フレームごとに埋め込みポーズの有無を分類します。以下のセクションでは、モデルの訓練データ、評価結果、使用例などについて詳しく説明します。
✨ 主な機能
- 音声の 20ms フレーム単位での埋め込みポーズの有無を分類します。
- 複数の言語(スロベニア語、クロアチア語、セルビア語、チェコ語、ポーランド語)に対応しています。
- 事後処理を行うことで、モデルの性能を向上させることができます。
📦 インストール
このモデルは Hugging Face の Transformers ライブラリを使用しています。必要なライブラリをインストールするには、以下のコマンドを実行してください。
pip install transformers datasets torch numpy pandas
💻 使用例
基本的な使用法
from transformers import AutoFeatureExtractor, Wav2Vec2BertForAudioFrameClassification
from datasets import Dataset, Audio
import torch
import numpy as np
from pathlib import Path
device = torch.device("cuda")
model_name = "classla/wav2vecbert2-filledPause"
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
model = Wav2Vec2BertForAudioFrameClassification.from_pretrained(model_name).to(device)
ds = Dataset.from_dict(
{
"audio": [
"/cache/peterr/mezzanine_resources/filled_pauses/data/dev/Iriss-J-Gvecg-P500001-avd_2082.293_2112.194.wav"
],
}
).cast_column("audio", Audio(sampling_rate=16_000, mono=True))
def frames_to_intervals(
frames: list[int],
drop_short=True,
drop_initial=True,
drop_final=True,
short_cutoff_s=0.08,
) -> list[tuple[float]]:
"""Transforms a list of ones or zeros, corresponding to annotations on frame
levels, to a list of intervals ([start second, end second]).
Allows for additional filtering on duration (false positives are often
short) and start times (false positives starting at 0.0 are often an
artifact of poor segmentation).
:param list[int] frames: Input frame labels
:param bool drop_short: Drop everything shorter than short_cutoff_s,
defaults to True
:param bool drop_initial: Drop predictions starting at 0.0, defaults to True
:param bool drop_final: Drop predictions ending at audio end, defaults to True
:param float short_cutoff_s: Duration in seconds of shortest allowable
prediction, defaults to 0.08
:return list[tuple[float]]: List of intervals [start_s, end_s]
"""
from itertools import pairwise
import pandas as pd
results = []
ndf = pd.DataFrame(
data={
"time_s": [0.020 * i for i in range(len(frames))],
"frames": frames,
}
)
ndf = ndf.dropna()
indices_of_change = ndf.frames.diff()[ndf.frames.diff() != 0].index.values
for si, ei in pairwise(indices_of_change):
if ndf.loc[si : ei - 1, "frames"].mode()[0] == 0:
pass
else:
results.append(
(
round(ndf.loc[si, "time_s"], 3),
round(ndf.loc[ei, "time_s"], 3),
)
)
if drop_short and (len(results) > 0):
results = [i for i in results if (i[1] - i[0] >= short_cutoff_s)]
if drop_initial and (len(results) > 0):
results = [i for i in results if i[0] != 0.0]
if drop_final and (len(results) > 0):
results = [i for i in results if i[1] != 0.02 * len(frames)]
return results
def evaluator(chunks):
sampling_rate = chunks["audio"][0]["sampling_rate"]
with torch.no_grad():
inputs = feature_extractor(
[i["array"] for i in chunks["audio"]],
return_tensors="pt",
sampling_rate=sampling_rate,
).to(device)
logits = model(**inputs).logits
y_pred = np.array(logits.cpu()).argmax(axis=-1)
intervals = [frames_to_intervals(i) for i in y_pred]
return {"y_pred": y_pred.tolist(), "intervals": intervals}
ds = ds.map(evaluator, batched=True)
print(ds["y_pred"][0])
# Prints a list of 20ms frames: [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0....]
# with 0 indicating no filled pause detected in that frame
print(ds["intervals"][0])
# Prints the identified intervals as a list of [start_s, ends_s]:
# [[0.08, 0.28 ], ...]
📚 ドキュメント
訓練データ
このモデルは、人間によってアノテーションされたスロベニア語の音声コーパス ROG-Artur を使用して訓練されました。訓練データは、最大 30 秒の長さのチャンクに分割されました。
評価
モデルの出力は、20ms フレームごとの 0 または 1 の系列ですが、評価はイベントレベルで行われました。連続する出力 1 の範囲は、1 つのイベントとしてまとめられました。真のイベントと予測されたイベントが部分的に重複する場合、これは真陽性としてカウントされます。陽性クラスの精度、再現率、および F1 スコアを報告しています。
ROGコーパスでの評価
事後処理 | 再現率 | 精度 | F1スコア |
---|---|---|---|
なし | 0.981 | 0.955 | 0.968 |
ParlaSpeechコーパスでの評価
ParlaSpeechコレクション の各言語について、400 個のインスタンスがサンプリングされ、人間のアノテーターによってアノテーションされました。
ParlaSpeechコーパスは、ROGコーパスのように手動で分割するには大きすぎるため、推論時にいくつかの失敗モードが観察されました。事後処理を行うことで、結果を改善できることがわかりました。誤検出は、不適切な音声分割によって引き起こされることが観察されたため、音声の開始時点で始まる予測や音声の終了時点で終わる予測を無効にすることが有益です。もう 1 つの失敗モードは、非常に短いイベントを予測することです。そのため、非常に短い予測を無視することが安全に破棄できます。
事後処理を追加することで、モデルは以下のメトリクスを達成します。
言語 | 事後処理 | 再現率 | 精度 | F1スコア |
---|---|---|---|---|
CZ | 短い初期および最終予測を削除 | 0.889 | 0.859 | 0.874 |
HR | 短い初期および最終予測を削除 | 0.94 | 0.887 | 0.913 |
PL | 短い初期および最終予測を削除 | 0.903 | 0.947 | 0.924 |
RS | 短い初期および最終予測を削除 | 0.966 | 0.915 | 0.94 |
事後処理の詳細については、上記のコードスニペットの frames_to_intervals
関数を参照してください。
引用
近日公開予定です。
📄 ライセンス
このモデルは、Apache-2.0 ライセンスの下で公開されています。
プロパティ | 詳細 |
---|---|
モデルタイプ | 音声分類 |
ベースモデル | facebook/w2v-bert-2.0 |
訓練データ | 人間によってアノテーションされたスロベニア語の音声コーパス ROG-Artur |
評価指標 | F1、再現率、精度 |









