モデル概要
モデル特徴
モデル能力
使用事例
🚀 VoxLingua107 ECAPA - TDNN 話者言語識別モデル
このモデルは、音声の言語を識別するためのモデルです。SpeechBrainを使用してVoxLingua107データセットで訓練されており、107種類の言語を識別できます。
🚀 クイックスタート
このモデルを使用するには、まず必要なライブラリをインストールする必要があります。以下のコマンドを実行してください。
pip install git+https://github.com/speechbrain/speechbrain.git@develop
次に、以下のPythonコードを使用してモデルをロードし、音声ファイルの言語を識別することができます。
import torchaudio
from speechbrain.inference.classifiers import EncoderClassifier
language_id = EncoderClassifier.from_hparams(source="speechbrain/lang-id-voxlingua107-ecapa", savedir="tmp")
# Download Thai language sample from Omniglot and cvert to suitable form
signal = language_id.load_audio("speechbrain/lang-id-voxlingua107-ecapa/udhr_th.wav")
prediction = language_id.classify_batch(signal)
print(prediction)
# (tensor([[-2.8646e+01, -3.0346e+01, -2.0748e+01, -2.9562e+01, -2.2187e+01,
# -3.2668e+01, -3.6677e+01, -3.3573e+01, -3.2545e+01, -2.4365e+01,
# -2.4688e+01, -3.1171e+01, -2.7743e+01, -2.9918e+01, -2.4770e+01,
# -3.2250e+01, -2.4727e+01, -2.6087e+01, -2.1870e+01, -3.2821e+01,
# -2.2128e+01, -2.2822e+01, -3.0888e+01, -3.3564e+01, -2.9906e+01,
# -2.2392e+01, -2.5573e+01, -2.6443e+01, -3.2429e+01, -3.2652e+01,
# -3.0030e+01, -2.4607e+01, -2.2967e+01, -2.4396e+01, -2.8578e+01,
# -2.5153e+01, -2.8475e+01, -2.6409e+01, -2.5230e+01, -2.7957e+01,
# -2.6298e+01, -2.3609e+01, -2.5863e+01, -2.8225e+01, -2.7225e+01,
# -3.0486e+01, -2.1185e+01, -2.7938e+01, -3.3155e+01, -1.9076e+01,
# -2.9181e+01, -2.2160e+01, -1.8352e+01, -2.5866e+01, -3.3636e+01,
# -4.2016e+00, -3.1581e+01, -3.1894e+01, -2.7834e+01, -2.5429e+01,
# -3.2235e+01, -3.2280e+01, -2.8786e+01, -2.3366e+01, -2.6047e+01,
# -2.2075e+01, -2.3770e+01, -2.2518e+01, -2.8101e+01, -2.5745e+01,
# -2.6441e+01, -2.9822e+01, -2.7109e+01, -3.0225e+01, -2.4566e+01,
# -2.9268e+01, -2.7651e+01, -3.4221e+01, -2.9026e+01, -2.6009e+01,
# -3.1968e+01, -3.1747e+01, -2.8156e+01, -2.9025e+01, -2.7756e+01,
# -2.8052e+01, -2.9341e+01, -2.8806e+01, -2.1636e+01, -2.3992e+01,
# -2.3794e+01, -3.3743e+01, -2.8332e+01, -2.7465e+01, -1.5085e-02,
# -2.9094e+01, -2.1444e+01, -2.9780e+01, -3.6046e+01, -3.7401e+01,
# -3.0888e+01, -3.3172e+01, -1.8931e+01, -2.2679e+01, -3.0225e+01,
# -2.4995e+01, -2.1028e+01]]), tensor([-0.0151]), tensor([94]), ['th'])
# The scores in the prediction[0] tensor can be interpreted as log-likelihoods that
# the given utterance belongs to the given language (i.e., the larger the better)
# The linear-scale likelihood can be retrieved using the following:
print(prediction[1].exp())
# tensor([0.9850])
# The identified language ISO code is given in prediction[3]
print(prediction[3])
# ['th: Thai']
# Alternatively, use the utterance embedding extractor:
emb = language_id.encode_batch(signal)
print(emb.shape)
# torch.Size([1, 1, 256])
GPUで推論を行う場合は、from_hparams
メソッドを呼び出す際にrun_opts={"device":"cuda"}
を追加してください。
✨ 主な機能
- このモデルは、107種類の異なる言語(アブハズ語、アフリカーンス語、アムハラ語、アラビア語など)に対応しており、音声発話を言語に応じて分類することができます。
- モデルは、以前に話者認識に使用されていたECAPA - TDNNアーキテクチャを使用していますが、埋め込み層の後により多くの全結合隠れ層を使用し、クロスエントロピー損失を使用して訓練されています。これにより、下流タスクのための抽出された発話埋め込みの性能が向上しました。
- システムは、16kHzでサンプリングされた録音(単一チャンネル)で訓練されています。コードは、必要に応じて
classify_file
を呼び出す際に自動的に音声を正規化します(すなわち、リサンプリング + モノチャンネル選択)。
📦 インストール
pip install git+https://github.com/speechbrain/speechbrain.git@develop
💻 使用例
基本的な使用法
import torchaudio
from speechbrain.inference.classifiers import EncoderClassifier
language_id = EncoderClassifier.from_hparams(source="speechbrain/lang-id-voxlingua107-ecapa", savedir="tmp")
# Download Thai language sample from Omniglot and cvert to suitable form
signal = language_id.load_audio("speechbrain/lang-id-voxlingua107-ecapa/udhr_th.wav")
prediction = language_id.classify_batch(signal)
print(prediction)
# (tensor([[-2.8646e+01, -3.0346e+01, -2.0748e+01, -2.9562e+01, -2.2187e+01,
# -3.2668e+01, -3.6677e+01, -3.3573e+01, -3.2545e+01, -2.4365e+01,
# -2.4688e+01, -3.1171e+01, -2.7743e+01, -2.9918e+01, -2.4770e+01,
# -3.2250e+01, -2.4727e+01, -2.6087e+01, -2.1870e+01, -3.2821e+01,
# -2.2128e+01, -2.2822e+01, -3.0888e+01, -3.3564e+01, -2.9906e+01,
# -2.2392e+01, -2.5573e+01, -2.6443e+01, -3.2429e+01, -3.2652e+01,
# -3.0030e+01, -2.4607e+01, -2.2967e+01, -2.4396e+01, -2.8578e+01,
# -2.5153e+01, -2.8475e+01, -2.6409e+01, -2.5230e+01, -2.7957e+01,
# -2.6298e+01, -2.3609e+01, -2.5863e+01, -2.8225e+01, -2.7225e+01,
# -3.0486e+01, -2.1185e+01, -2.7938e+01, -3.3155e+01, -1.9076e+01,
# -2.9181e+01, -2.2160e+01, -1.8352e+01, -2.5866e+01, -3.3636e+01,
# -4.2016e+00, -3.1581e+01, -3.1894e+01, -2.7834e+01, -2.5429e+01,
# -3.2235e+01, -3.2280e+01, -2.8786e+01, -2.3366e+01, -2.6047e+01,
# -2.2075e+01, -2.3770e+01, -2.2518e+01, -2.8101e+01, -2.5745e+01,
# -2.6441e+01, -2.9822e+01, -2.7109e+01, -3.0225e+01, -2.4566e+01,
# -2.9268e+01, -2.7651e+01, -3.4221e+01, -2.9026e+01, -2.6009e+01,
# -3.1968e+01, -3.1747e+01, -2.8156e+01, -2.9025e+01, -2.7756e+01,
# -2.8052e+01, -2.9341e+01, -2.8806e+01, -2.1636e+01, -2.3992e+01,
# -2.3794e+01, -3.3743e+01, -2.8332e+01, -2.7465e+01, -1.5085e-02,
# -2.9094e+01, -2.1444e+01, -2.9780e+01, -3.6046e+01, -3.7401e+01,
# -3.0888e+01, -3.3172e+01, -1.8931e+01, -2.2679e+01, -3.0225e+01,
# -2.4995e+01, -2.1028e+01]]), tensor([-0.0151]), tensor([94]), ['th'])
# The scores in the prediction[0] tensor can be interpreted as log-likelihoods that
# the given utterance belongs to the given language (i.e., the larger the better)
# The linear-scale likelihood can be retrieved using the following:
print(prediction[1].exp())
# tensor([0.9850])
# The identified language ISO code is given in prediction[3]
print(prediction[3])
# ['th: Thai']
# Alternatively, use the utterance embedding extractor:
emb = language_id.encode_batch(signal)
print(emb.shape)
# torch.Size([1, 1, 256])
高度な使用法
GPUで推論を行う場合は、from_hparams
メソッドを呼び出す際にrun_opts={"device":"cuda"}
を追加します。
import torchaudio
from speechbrain.inference.classifiers import EncoderClassifier
language_id = EncoderClassifier.from_hparams(source="speechbrain/lang-id-voxlingua107-ecapa", savedir="tmp", run_opts={"device":"cuda"})
# 以下同様に音声識別のコードを記述
📚 ドキュメント
意図された用途と制限
- モデルには2つの用途があります。
- そのまま話者言語認識に使用する。
- 独自のデータで専用の言語識別モデルを作成するための発話レベルの特徴(埋め込み)抽出器として使用する。
- モデルは、自動的に収集されたYouTubeデータで訓練されています。データセットに関する詳細情報は、こちらを参照してください。
制限とバイアス
モデルはVoxLingua107で訓練されているため、多くの制限とバイアスがあります。いくつかの例を挙げると、以下の通りです。
- 小規模な言語に対する精度はかなり限られている可能性があります。
- YouTubeデータには男性の音声がはるかに多く含まれているため、女性の音声に対する性能は男性の音声よりも悪い可能性があります。
- 主観的な実験に基づくと、外国のアクセントのある音声に対してはうまく機能しません。
- 子供の音声や言語障害のある人の音声に対してはうまく機能しない可能性があります。
訓練データ
モデルはVoxLingua107で訓練されています。VoxLingua107は、話者言語識別モデルを訓練するための音声データセットです。データセットは、YouTube動画から自動的に抽出された短い音声セグメントで構成されており、動画のタイトルと説明の言語に従ってラベル付けされ、誤検出を除外するためのいくつかの後処理ステップが行われています。VoxLingua107には107種類の言語のデータが含まれており、訓練セットの音声の総量は6628時間です。言語ごとの平均データ量は62時間ですが、実際の言語ごとの量は大きく異なります。また、33種類の言語からの1609個の音声セグメントを含む別の開発セットもあり、少なくとも2人のボランティアによって実際に指定された言語が含まれていることが検証されています。
訓練手順
SpeechBrainレシピを参照してください。
評価結果
VoxLingua107開発データセットでの誤り率は6.7%です。
参照情報
SpeechBrainの参照
@misc{speechbrain,
title={{SpeechBrain}: A General-Purpose Speech Toolkit},
author={Mirco Ravanelli and Titouan Parcollet and Peter Plantinga and Aku Rouhe and Samuele Cornell and Loren Lugosch and Cem Subakan and Nauman Dawalatabad and Abdelwahab Heba and Jianyuan Zhong and Ju-Chieh Chou and Sung-Lin Yeh and Szu-Wei Fu and Chien-Feng Liao and Elena Rastorgueva and François Grondin and William Aris and Hwidong Na and Yan Gao and Renato De Mori and Yoshua Bengio},
year={2021},
eprint={2106.04624},
archivePrefix={arXiv},
primaryClass={eess.AS},
note={arXiv:2106.04624}
}
VoxLingua107の参照
@inproceedings{valk2021slt,
title={{VoxLingua107}: a Dataset for Spoken Language Recognition},
author={J{\"o}rgen Valk and Tanel Alum{\"a}e},
booktitle={Proc. IEEE SLT Workshop},
year={2021},
}
SpeechBrainについて
SpeechBrainは、オープンソースの統合型音声ツールキットです。シンプルで非常に柔軟性が高く、ユーザーフレンドリーに設計されています。様々なドメインで競争力のある、または最先端の性能が得られます。
- ウェブサイト: https://speechbrain.github.io/
- GitHub: https://github.com/speechbrain/speechbrain
🔧 技術詳細
モデルは、以前に話者認識に使用されていたECAPA - TDNNアーキテクチャを使用していますが、埋め込み層の後により多くの全結合隠れ層を使用し、クロスエントロピー損失を使用して訓練されています。これにより、下流タスクのための抽出された発話埋め込みの性能が向上しました。
📄 ライセンス
このモデルは、Apache - 2.0ライセンスの下で提供されています。
⚠️ 重要提示
- データセットおよびこのモデルのデフォルト設定(
label_encoder.txt
を参照)では、ヘブライ語に使用されているISO言語コードは廃止されています(iw
ではなくhe
にすべきです)。ジャワ語のISO言語コードも誤っています(jw
ではなくjv
にすべきです)。詳細はissue #2396を参照してください。 - システムは、16kHzでサンプリングされた録音(単一チャンネル)で訓練されています。コードは、必要に応じて
classify_file
を呼び出す際に自動的に音声を正規化します(すなわち、リサンプリング + モノチャンネル選択)。encode_batch
やclassify_batch
を使用する場合は、入力テンソルが予期されるサンプリングレートに準拠していることを確認してください。
💡 使用建议
- GPUで推論を行う場合は、
from_hparams
メソッドを呼び出す際にrun_opts={"device":"cuda"}
を追加することで、処理速度を向上させることができます。









