Transformers documentation
VibeVoice ASR
このモデルは2026年1月26日にHF papersで公開され、2026年3月2日にHugging Face Transformersに貢献されました。
VibeVoice ASR
概要
VibeVoice ASR は、Microsoft による自動音声認識モデルです。音響トークナイザーと意味論的オーディオトークナイザーを因果言語モデルと組み合わせることで、堅牢な音声からテキストへの書き起こしを実現します。このモデルは、24kHz でオーディオを処理する VibeVoice の音響トークナイザーと意味論的トークナイザーを使用し、書き起こしの生成には Qwen2 ベースの言語デコーダーを組み合わせます。詳細については、技術レポートを参照してください。
モデルのチェックポイントは、microsoft/VibeVoice-ASR-HF で利用可能です。
ハイライト:
🕒 60分間のワンパス処理: 従来のASRモデルは、オーディオを短いチャンクに分割して処理するため(多くの場合、グローバルなコンテキストが失われる)、VibeVoice ASRは64Kトークン長の範囲内で最大60分間の連続オーディオ入力を受け入れます。これにより、1時間全体にわたって一貫した話者トラッキングと意味の一貫性が確保されます。
👤 カスタムホットワード: ユーザーは、認識プロセスをガイドするためにカスタムホットワード(特定の固有名詞、技術用語、背景情報など)を指定できます。これにより、ドメイン固有のコンテンツに対する認識精度が大幅に向上します。
📝 リッチトランスクリプション(誰が、いつ、何を言ったか): モデルはASR、話者分離、タイムスタンプ付与を同時に実行し、誰が何を、いつ言ったかを示す構造化された出力を生成します。
🌍 多言語およびコードスイッチングのサポート: 50以上の言語に対応しており、明示的な言語設定は不要です。また、発話内および発話間のコードスイッチングをネイティブで処理します。
このモデルはEric Bezzamによって提供されました。
使用方法
このモデルは、さまざまな自動音声認識機能に対応しています。
話者付きタイムスタンプ付き文字起こし
VibeVoice ASRの注目すべき機能の一つは、複数話者のコンテンツを文字起こしし、誰がいつ発言したかを特定できる点です。
from transformers import AutoProcessor, VibeVoiceAsrForConditionalGeneration
model_id = "microsoft/VibeVoice-ASR-HF"
processor = AutoProcessor.from_pretrained(model_id)
model = VibeVoiceAsrForConditionalGeneration.from_pretrained(model_id, device_map="auto")
print(f"Model loaded on {model.device} with dtype {model.dtype}")
# Prepare inputs using `apply_transcription_request`
inputs = processor.apply_transcription_request(
audio="https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/example_output/VibeVoice-1.5B_output.wav",
).to(model.device, model.dtype)
# Apply model
output_ids = model.generate(**inputs)
generated_ids = output_ids[:, inputs["input_ids"].shape[1] :]
transcription = processor.decode(generated_ids)[0]
print("\n" + "=" * 60)
print("RAW OUTPUT")
print("=" * 60)
print(transcription)
transcription = processor.decode(generated_ids, return_format="parsed")[0]
print("\n" + "=" * 60)
print("TRANSCRIPTION (list of dicts)")
print("=" * 60)
for speaker_transcription in transcription:
print(speaker_transcription)
# Remove speaker labels, only get raw transcription
transcription = processor.decode(generated_ids, return_format="transcription_only")[0]
print("\n" + "=" * 60)
print("TRANSCRIPTION ONLY")
print("=" * 60)
print(transcription)
"""
============================================================
RAW OUTPUT
============================================================
<|im_start|>assistant
[{"Start":0,"End":15.43,"Speaker":0,"Content":"Hello everyone and welcome to the Vibe Voice podcast. I'm your host, Alex, and today we're getting into one of the biggest debates in all of sports: who's the greatest basketball player of all time? I'm so excited to have Sam here to talk about it with me."},{"Start":15.43,"End":21.05,"Speaker":1,"Content":"Thanks so much for having me, Alex. And you're absolutely right. This question always brings out some seriously strong feelings."},{"Start":21.05,"End":31.66,"Speaker":0,"Content":"Okay, so let's get right into it. For me, it has to be Michael Jordan. Six trips to the finals, six championships. That kind of perfection is just incredible."},{"Start":31.66,"End":40.93,"Speaker":1,"Content":"Oh man, the first thing that always pops into my head is that shot against the Cleveland Cavaliers back in '89. Jordan just rises, hangs in the air forever, and just sinks it."}]<|im_end|>
<|endoftext|>
============================================================
TRANSCRIPTION (list of dicts)
============================================================
{'Start': 0, 'End': 15.43, 'Speaker': 0, 'Content': "Hello everyone and welcome to the Vibe Voice podcast. I'm your host, Alex, and today we're getting into one of the biggest debates in all of sports: who's the greatest basketball player of all time? I'm so excited to have Sam here to talk about it with me."}
{'Start': 15.43, 'End': 21.05, 'Speaker': 1, 'Content': "Thanks so much for having me, Alex. And you're absolutely right. This question always brings out some seriously strong feelings."}
{'Start': 21.05, 'End': 31.66, 'Speaker': 0, 'Content': "Okay, so let's get right into it. For me, it has to be Michael Jordan. Six trips to the finals, six championships. That kind of perfection is just incredible."}
{'Start': 31.66, 'End': 40.93, 'Speaker': 1, 'Content': "Oh man, the first thing that always pops into my head is that shot against the Cleveland Cavaliers back in '89. Jordan just rises, hangs in the air forever, and just sinks it."}
============================================================
TRANSCRIPTION ONLY
============================================================
Hello everyone and welcome to the Vibe Voice podcast. I'm your host, Alex, and today we're getting into one of the biggest debates in all of sports: who's the greatest basketball player of all time? I'm so excited to have Sam here to talk about it with me. Thanks so much for having me, Alex. And you're absolutely right. This question always brings out some seriously strong feelings. Okay, so let's get right into it. For me, it has to be Michael Jordan. Six trips to the finals, six championships. That kind of perfection is just incredible. Oh man, the first thing that always pops into my head is that shot against the Cleveland Cavaliers back in '89. Jordan just rises, hangs in the air forever, and just sinks it.
"""VibeVoice ASR モデルは、JSON 構造に似た文字列を生成するように学習されています。return_format="parsed" フラグは、生成された出力を dict のリストとして返そうとしますが、return_format="transcription_only" は、書き起こされた音声のみを抽出しようとします。いずれも失敗した場合、生成された出力はそのまま返されます。
コンテキストの提供
コンテキストを指定することも可能です。固有名詞のように、正しく文字起こしできない単語がある場合に便利です。
以下では、ドイツ訛りのある話者が「About VibeVoice」というコンテキストの有無を比較しながら、VibeVoice について語る音声の文字起こしを示します。
from transformers import AutoProcessor, VibeVoiceAsrForConditionalGeneration
model_id = "microsoft/VibeVoice-ASR-HF"
processor = AutoProcessor.from_pretrained(model_id)
model = VibeVoiceAsrForConditionalGeneration.from_pretrained(model_id, device_map="auto")
print(f"Model loaded on {model.device} with dtype {model.dtype}")
# Without context
inputs = processor.apply_transcription_request(
audio="https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/realtime_model/vibevoice_tts_german.wav",
).to(model.device, model.dtype)
output_ids = model.generate(**inputs)
generated_ids = output_ids[:, inputs["input_ids"].shape[1] :]
transcription = processor.decode(generated_ids, return_format="transcription_only")[0]
print(f"WITHOUT CONTEXT: {transcription}")
# With context
inputs = processor.apply_transcription_request(
audio="https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/realtime_model/vibevoice_tts_german.wav",
prompt="About VibeVoice",
).to(model.device, model.dtype)
output_ids = model.generate(**inputs)
generated_ids = output_ids[:, inputs["input_ids"].shape[1] :]
transcription = processor.decode(generated_ids, return_format="transcription_only")[0]
print(f"WITH CONTEXT : {transcription}")
"""
WITHOUT CONTEXT: Revevoices is a novel framework designed for generating expressive, long-form, multi-speaker conversational audio.
WITH CONTEXT : VibeVoice is this novel framework designed for generating expressive, long-form, multi-speaker, conversational audio.
"""バッチ推論
オーディオのリストを渡すことで、バッチ推論が可能です。プロンプトが提供されている場合は、プロンプトのリストも渡します。オーディオ入力とプロンプトの数は一致させる必要があります(プロンプトについては、特定のオーディオに対して不要な場合は、そのエントリをNoneに設定できます)。
from transformers import AutoProcessor, VibeVoiceAsrForConditionalGeneration
model_id = "microsoft/VibeVoice-ASR-HF"
audio = [
"https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/realtime_model/vibevoice_tts_german.wav",
"https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/example_output/VibeVoice-1.5B_output.wav"
]
prompts = ["About VibeVoice", None]
processor = AutoProcessor.from_pretrained(model_id)
model = VibeVoiceAsrForConditionalGeneration.from_pretrained(model_id, device_map="auto")
print(f"Model loaded on {model.device} with dtype {model.dtype}")
inputs = processor.apply_transcription_request(audio, prompt=prompts).to(model.device, model.dtype)
output_ids = model.generate(**inputs)
generated_ids = output_ids[:, inputs["input_ids"].shape[1] :]
transcription = processor.decode(generated_ids, return_format="transcription_only")
print(transcription)トークナイザのチャンクを調整する(メモリ不足の場合など)
VibeVoice ASRの重要な機能の一つは、最大60分間の連続音声を書き起こせることです。これは、音声を60秒のセグメント(24kHzで1440000サンプル)に分割し、各セグメント間で畳み込み状態をキャッシュすることで実現されています。
ただし、60秒のチャンクがデバイスに対して大きすぎる場合は、generateに渡すacoustic_tokenizer_chunk_size引数を調整できます。ホップ長(元のacoustic tokenizerでは3200)の倍数である必要があります。
from transformers import AutoProcessor, VibeVoiceAsrForConditionalGeneration
acoustic_tokenizer_chunk_size = 64000 # default is 1440000 (60s @ 24kHz)
model_id = "microsoft/VibeVoice-ASR-HF"
audio = [
"https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/realtime_model/vibevoice_tts_german.wav",
"https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/example_output/VibeVoice-1.5B_output.wav"
]
prompts = ["About VibeVoice", None]
processor = AutoProcessor.from_pretrained(model_id)
model = VibeVoiceAsrForConditionalGeneration.from_pretrained(model_id, device_map="auto")
print(f"Model loaded on {model.device} with dtype {model.dtype}")
inputs = processor.apply_transcription_request(audio, prompt=prompts).to(model.device, model.dtype)
output_ids = model.generate(**inputs, acoustic_tokenizer_chunk_size=acoustic_tokenizer_chunk_size)
generated_ids = output_ids[:, inputs["input_ids"].shape[1] :]
transcription = processor.decode(generated_ids, return_format="transcription_only")
print(transcription)チャットテンプレート
VibeVoice ASR はチャットテンプレートの入力も受け入れます(apply_transcription_request は便宜上、apply_chat_template のラッパーです):
from transformers import AutoProcessor, VibeVoiceAsrForConditionalGeneration
model_id = "microsoft/VibeVoice-ASR-HF"
processor = AutoProcessor.from_pretrained(model_id)
model = VibeVoiceAsrForConditionalGeneration.from_pretrained(model_id, device_map="auto")
chat_template = [
[
{
"role": "user",
"content": [
{"type": "text", "text": "About VibeVoice"},
{
"type": "audio",
"path": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/realtime_model/vibevoice_tts_german.wav",
},
],
}
],
[
{
"role": "user",
"content": [
{
"type": "audio",
"path": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/example_output/VibeVoice-1.5B_output.wav",
},
],
}
],
]
inputs = processor.apply_chat_template(
chat_template,
tokenize=True,
return_dict=True,
).to(model.device, model.dtype)
output_ids = model.generate(**inputs)
generated_ids = output_ids[:, inputs["input_ids"].shape[1] :]
transcription = processor.decode(generated_ids, return_format="transcription_only")
print(transcription)トレーニング
VibeVoice ASRは、モデルが出力する損失で学習できます。
from transformers import AutoProcessor, VibeVoiceAsrForConditionalGeneration
model_id = "microsoft/VibeVoice-ASR-HF"
processor = AutoProcessor.from_pretrained(model_id)
model = VibeVoiceAsrForConditionalGeneration.from_pretrained(model_id, device_map="auto")
model.train()
# Prepare batch of 2
# -- NOTE: the original model is trained to output transcription, speaker ID, and timestamps in JSON-like format. Below we are only using the transcription text as the label
chat_template = [
[
{
"role": "user",
"content": [
{"type": "text", "text": "VibeVoice is this novel framework designed for generating expressive, long-form, multi-speaker, conversational audio."},
{
"type": "audio",
"path": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/realtime_model/vibevoice_tts_german.wav",
},
],
}
],
[
{
"role": "user",
"content": [
{"type": "text", "text": "Hello everyone and welcome to the VibeVoice podcast. I'm your host, Alex, and today we're getting into one of the biggest debates in all of sports: who's the greatest basketball player of all time? I'm so excited to have Sam here to talk about it with me. Thanks so much for having me, Alex. And you're absolutely right. This question always brings out some seriously strong feelings. Okay, so let's get right into it. For me, it has to be Michael Jordan. Six trips to the finals, six championships. That kind of perfection is just incredible. Oh man, the first thing that always pops into my head is that shot against the Cleveland Cavaliers back in '89. Jordan just rises, hangs in the air forever, and just sinks it."},
{
"type": "audio",
"path": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/example_output/VibeVoice-1.5B_output.wav",
},
],
}
],
]
inputs = processor.apply_chat_template(
chat_template,
tokenize=True,
return_dict=True,
output_labels=True,
).to(model.device, model.dtype)
loss = model(**inputs).loss
print("Loss:", loss.item())
loss.backward()Torch compile
モデルは、より高速な推論/学習のためにコンパイルできます。
import time
import torch
from transformers import AutoProcessor, VibeVoiceAsrForConditionalGeneration
model_id = "microsoft/VibeVoice-ASR-HF"
num_warmup = 5
num_runs = 20
# Load processor + model
processor = AutoProcessor.from_pretrained(model_id)
model = VibeVoiceAsrForConditionalGeneration.from_pretrained(model_id, device_map="auto")
# Prepare static inputs
chat_template = [
[
{
"role": "user",
"content": [
{
"type": "text",
"text": "VibeVoice is this novel framework designed for generating expressive, long-form, multi-speaker, conversational audio.",
},
{
"type": "audio",
"path": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/realtime_model/vibevoice_tts_german.wav",
},
],
}
],
] * 4 # batch size 4
inputs = processor.apply_chat_template(
chat_template,
tokenize=True,
return_dict=True,
).to(model.device, torch.bfloat16)
# Benchmark without compile
print("Warming up without compile...")
with torch.no_grad():
for _ in range(num_warmup):
_ = model(**inputs)
torch.accelerator.synchronize()
print("\nBenchmarking without torch.compile...")
torch.accelerator.synchronize()
start = time.time()
with torch.no_grad():
for _ in range(num_runs):
_ = model(**inputs)
torch.accelerator.synchronize()
no_compile_time = (time.time() - start) / num_runs
print(f"Average time without compile: {no_compile_time:.4f}s")
# Benchmark with compile
print("\nCompiling model...")
model = torch.compile(model)
print("Warming up with compile (includes graph capture)...")
with torch.no_grad():
for _ in range(num_warmup):
_ = model(**inputs)
torch.accelerator.synchronize()
print("\nBenchmarking with torch.compile...")
torch.accelerator.synchronize()
start = time.time()
with torch.no_grad():
for _ in range(num_runs):
_ = model(**inputs)
torch.accelerator.synchronize()
compile_time = (time.time() - start) / num_runs
print(f"Average time with compile: {compile_time:.4f}s")
speedup = no_compile_time / compile_time
print(f"\nSpeedup: {speedup:.2f}x")Pipelineの使用方法
モデルはパイプラインとして使用できますが、生出力の解析には独自のメソッドを定義する必要があります。
from transformers import pipeline
model_id = "microsoft/VibeVoice-ASR-HF"
pipe = pipeline("any-to-any", model=model_id, device_map="auto")
chat_template = [
{
"role": "user",
"content": [
{"type": "text", "text": "About VibeVoice"},
{
"type": "audio",
"path": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/realtime_model/vibevoice_tts_german.wav",
},
],
}
]
outputs = pipe(text=chat_template, return_full_text=False)
print("\n" + "=" * 60)
print("RAW PIPELINE OUTPUT")
print("=" * 60)
print(outputs[0]["generated_text"])
print("\n" + "=" * 60)
print("DICT OUTPUT")
print("=" * 60)
dict_output = pipe.processor.extract_speaker_dict(outputs[0]["generated_text"])
print(dict_output)
print("\n" + "=" * 60)
print("TRANSCRIPT OUTPUT")
print("=" * 60)
transcription = pipe.processor.extract_transcription(outputs[0]["generated_text"])
print(transcription)VibeVoiceAsrConfig
class transformers.VibeVoiceAsrConfig
< source >( transformers_version: str | None = Nonearchitectures: list[str] | None = Noneoutput_hidden_states: bool | None = Falsereturn_dict: bool | None = Truedtype: str | torch.dtype | None = Nonechunk_size_feed_forward: int = 0is_encoder_decoder: bool = Falseid2label: dict[int, str] | dict[str, str] | None = Nonelabel2id: dict[str, int] | dict[str, str] | None = Noneproblem_type: Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = Noneacoustic_tokenizer_encoder_config: dict | transformers.configuration_utils.PreTrainedConfig | None = Nonesemantic_tokenizer_encoder_config: dict | transformers.configuration_utils.PreTrainedConfig | None = Nonetext_config: dict | transformers.configuration_utils.PreTrainedConfig | None = Noneaudio_token_id: int = 151648audio_bos_token_id: int = 151646audio_eos_token_id: int = 151647acoustic_tokenizer_chunk_size: int = 1440000 )
パラメータ
- acoustic_tokenizer_encoder_config (
Union[VibeVoiceAcousticTokenizerConfig, dict]、任意) — 音響トークナイザーの設定オブジェクトまたは辞書です。このトークナイザーは、音声から音響特徴量を抽出します。 - semantic_tokenizer_encoder_config (
Union[VibeVoiceAcousticTokenizerConfig, dict]、任意) — セマンティック トークナイザーの設定オブジェクトまたは辞書です。このトークナイザーは、音声からセマンティックな特徴量を抽出します。 - text_config (
Union[dict, ~configuration_utils.PreTrainedConfig]、省略可) — テキストバックボーンの設定オブジェクトまたは辞書。 - audio_token_id (
int、任意、デフォルトは151648) — 入力音声のプレースホルダーとして使用されるオーディオトークンのインデックスです。 - audio_bos_token_id (
int、任意、デフォルト値は 151646) — オーディオのシーケンス開始トークンのインデックスです。 - audio_eos_token_id (
int、任意、デフォルトは 151647) — オーディオのシーケンス終了トークンのインデックスです。 - acoustic_tokenizer_chunk_size (
int、任意、デフォルトは 1440000)— オーディオ入力をトークナイズする際に使用するチャンクサイズ(サンプル数)。デフォルト値は 24kHz で 60 秒分に相当します。
これは、VibeVoiceAsrModel の設定を保存するための設定クラスです。指定された引数に基づいて Vibevoice Asr モデルをインスタンス化し、モデルのアーキテクチャを定義するために使用されます。デフォルト値で設定をインスタンス化すると、microsoft/VibeVoice-ASR-HF と同様の設定が得られます。
設定オブジェクトはPreTrainedConfigを継承し、モデルの出力を制御するために使用できます。詳細については、PreTrainedConfigのドキュメントを参照してください。
例:
>>> from transformers import VibeVoiceAsrForConditionalGeneration, VibeVoiceAsrConfig, VibeVoiceAcousticTokenizerEncoderConfig, Qwen2Config
>>> # Initializing VibeVoice acoustic and semantic encoder configs
>>> acoustic_config = VibeVoiceAcousticTokenizerEncoderConfig()
>>> semantic_config = VibeVoiceAcousticTokenizerEncoderConfig(hidden_size=128)
>>> # Initializing a Qwen2 config
>>> text_config = Qwen2Config()
>>> # Initializing a VibeVoice ASR configuration
>>> configuration = VibeVoiceAsrConfig(acoustic_config, semantic_config, text_config)
>>> # Initializing a model from the vibevoice_asr style configuration
>>> model = VibeVoiceAsrForConditionalGeneration(configuration)
>>> # Accessing the model configuration
>>> configuration = model.configVibeVoiceAsrProcessor
クラス transformers.VibeVoiceAsrProcessor
< source >( feature_extractortokenizerchat_template = Noneaudio_token = '<|box_start|>'audio_bos_token = '<|object_ref_start|>'audio_eos_token = '<|object_ref_end|>'audio_duration_token = '<|AUDIO_DURATION|>' )
パラメータ
- feature_extractor (
VibeVoiceAcousticTokenizerFeatureExtractor) — 音声処理用のフィーチャーエクストラクターです。 - tokenizer (
Qwen2TokenizerFast) — テキスト処理用のトークナイザーです。 - chat_template (
str、省略可) — チャットのメッセージのリストをトークン化可能な文字列に変換するために使用される Jinja テンプレートです。 - audio_token (
str、任意、デフォルトは"<|box_start|>") — チャットテンプレートで使用するオーディオトークンのプレースホルダーです。 - audio_bos_token (
str、任意、デフォルトは"<|object_ref_start|>") — チャットテンプレートで使用する、音声のシーケンス開始トークンのプレースホルダーです。 - audio_eos_token (
str、任意、デフォルトは"<|object_ref_end|>") — チャットテンプレートで使用する、音声のシーケンス終了トークンのプレースホルダーです。 - audio_duration_token (
str、任意、デフォルトは"<|AUDIO_DURATION|>") — チャットテンプレートで使用するオーディオの再生時間トークンのプレースホルダーです。
VibeVoiceAcousticTokenizerFeatureExtractor と Qwen2TokenizerFast を単一のプロセッサーにラップし、音声特徴抽出とトークナイザーの両方の機能を受け継ぐ VibeVoice ASR プロセッサーを構築します。
詳細については、call()を参照してください。
__call__
< source >( text: str | list[str]audio: typing.Union[numpy.ndarray, ForwardRef('torch.Tensor'), collections.abc.Sequence[numpy.ndarray], collections.abc.Sequence['torch.Tensor'], NoneType] = Noneoutput_labels: bool | None = False**kwargs: *<class 'transformers.models.vibevoice_asr.processing_vibevoice_asr.VibeVoiceAsrProcessorKwargs'> ) → BatchFeature
パラメータ
- text (
Union[str, list[str]]) — エンコード対象のシーケンスまたはシーケンスのバッチです。各シーケンスは文字列または文字列のリスト(事前トークン化済み文字列)であることができます。事前トークン化済み入力を渡す場合は、バッチ入力との曖昧さを避けるためにis_split_into_words=Trueを設定してください。 - audio (
Union[numpy.ndarray, torch.Tensor, collections.abc.Sequence[numpy.ndarray], collections.abc.Sequence[torch.Tensor]], 任意) — 準備対象のオーディオまたはオーディオのバッチです。各オーディオは NumPy 配列または PyTorch テンソルであることができます。 NumPy 配列/PyTorch テンソルの場合、各オーディオの形状は (C, T) である必要があります。ここで C はチャネル数、T はオーディオのサンプル長です。 - output_labels (
bool、省略可、デフォルト: False) — 学習用のラベルを返すかどうか。 - return_tensors (
strまたは TensorType, 省略可) — 設定すると、特定のフレームワークのテンソルを返します。使用可能な値は以下の通りです:'pt': PyTorchのtorch.Tensorオブジェクトを返します。'np': NumPyのnp.ndarrayオブジェクトを返します。
- **kwargs (ProcessingKwargs、任意) — 各モダリティ(テキスト、画像、動画、音声)の追加処理オプション。モデル固有のパラメータは上記にリストされています。サポートされている引数の完全なリストについては、TypedDictクラスを参照してください。
戻り値
トークン化されたテキスト(input_ids、attention_mask)と音声特徴(input_values、padding_mask)を含む辞書。
apply_transcription_request
< source >( audio: typing.Union[str, list[str], numpy.ndarray, ForwardRef('torch.Tensor'), collections.abc.Sequence[numpy.ndarray], collections.abc.Sequence['torch.Tensor']]prompt: str | list[str] | None = Nonetokenize: bool = True**kwargs: *<class 'transformers.models.vibevoice_asr.processing_vibevoice_asr.VibeVoiceAsrProcessorKwargs'> ) → BatchFeature or list[str]
パラメータ
- audio (
str、list[str]、np.ndarray、torch.Tensor、list[np.ndarray]、list[torch.Tensor]) — 文字起こしを行う音声です。文字列はローカルパスまたは URL として解釈され、チャットテンプレートローダーによって自動的に読み込まれます。NumPy 配列と PyTorch テンソルはそのまま転送されます。 - prompt (
strまたはlist[str]、省略可) — ユーザーターンに追加のコンテキストとして含めるカスタムプロンプトです。リストを指定する場合は、バッチと同じ長さである必要があります。Noneの場合、追加のコンテキストは提供されません。 - tokenize (
bool、省略可、デフォルトはTrue) — プロンプトをトークナイズし、オーディオを処理するかどうか。Falseの場合、オーディオは読み込まれず、プロンプトは展開されていないオーディオプレースホルダーを含む文字列として返されます。これらをオーディオとともにプロセッサに渡すprocessor(text=prompts, audio=audio)とすると、tokenize=Trueと同じ出力が得られます。 - **kwargs —
text_kwargs、audio_kwargsなど、apply_chat_template() に転送される追加のキーワード引数。
戻り値
BatchFeature または list[str]
tokenize=False の場合は 1 つのオーディオにつき 1 つのプロンプトが出力され、それ以外の場合は VibeVoiceAsrForConditionalGeneration.generate() にそのまま渡せる形式の出力が得られます。
手動でチャットテンプレートを書かずに、自動音声認識用の入力を準備します。
decode
< source >( *argsreturn_format = 'raw'**kwargs )
decode() に引数を転送し、必要に応じて dict 形式の出力を解析します。
VibeVoiceAsrModel
class transformers.VibeVoiceAsrModel
< source >( config: VibeVoiceAsrConfig )
パラメータ
- config (VibeVoiceAsrConfig) — モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、from_pretrained() メソッドを参照してください。
VibeVoice ASR モデル(音響トークナイザー + 意味トークナイザー + マルチモーダルプロジェクター + 言語モデル)、言語モデリングヘッドなし。
このモデルは PreTrainedModel を継承しています。すべてのモデルに実装されている汎用的なメソッド(ダウンロードや保存、入力埋め込みのリサイズ、ヘッドのプルーニングなど)については、スーパークラスのドキュメントを参照してください。
このモデルは、PyTorchのtorch.nn.Moduleのサブクラスでもあります。 通常のPyTorch Moduleとして使用し、一般的な使用方法や動作に関する詳細については、PyTorchのドキュメントを参照してください。
forward
< source >( input_ids: typing.Optional[torch.LongTensor] = Noneattention_mask: typing.Optional[torch.Tensor] = Nonepast_key_values: transformers.cache_utils.Cache | None = Noneinputs_embeds: typing.Optional[torch.FloatTensor] = Noneinput_values: typing.Optional[torch.FloatTensor] = Nonepadding_mask: typing.Optional[torch.BoolTensor] = Nonesample: bool = True**kwargs: *<class 'transformers.utils.generic.TransformersKwargs'> ) → VibeVoiceAsrModelOutputWithPast or tuple(torch.FloatTensor)
パラメータ
- input_ids (
torch.LongTensorの形状(batch_size, sequence_length), 、省略可) — 語彙における入力シーケンスのトークンインデックスです。デフォルトではパディングは無視されます。インデックスはAutoTokenizerを使用して取得できます。詳細については、PreTrainedTokenizer.encode()およびPreTrainedTokenizer.call()を参照してください。
- attention_mask (
torch.Tensorの形状(batch_size, sequence_length), 、任意) — パディングトークンのインデックスに対するアテンションを回避するためのマスク。[0, 1]:- マスクされていないトークンに対して1
- マスクされたトークンに対しては 0 です。
- past_key_values (
~cache_utils.Cache, 省略可) — 逐次デコードを高速化するために使用できる、事前計算された隠れ状態(自己アテンションブロックおよびクロスアテンションブロックのキーとバリュー)。通常、これはデコードの以前の段階でモデルが返したpast_key_valuesであり、use_cache=Trueまたはconfig.use_cache=True.入力として許可されるのは Cache インスタンスのみです。kv cache ガイドを参照してください。
past_key_valuesが渡されない場合、デフォルトで DynamicCache が初期化されます。モデルは、入力として与えられたのと同じキャッシュ形式を出力します。
past_key_valuesを使用する場合、すべてのinput_ids(形状(batch_size, sequence_length))ではなく、このモデルに過去のキー・バリュー状態が与えられていない未処理のinput_ids(形状(batch_size, unprocessed_length))のみを入力することになります。 - inputs_embeds (
torch.FloatTensor、形状(batch_size, sequence_length, hidden_size)、任意) —input_idsを渡す代わりに、埋め込み表現を直接渡すこともできます。これは、モデル内部の埋め込みルックアップ行列よりも、input_idsのインデックスを対応するベクトルに変換する方法をより細かく制御したい場合に有用です。 - input_values (
torch.FloatTensor、shape(batch_size, sequence_length)、任意) — 入力生の音声波形の浮動小数点値。値は、.flacまたは.wav形式のオーディオファイルをlist[float]、numpy.ndarray、またはtorch.Tensor型の配列として読み込むことで取得できます。例えば、torchcodec ライブラリ(pip install torchcodec)や soundfile ライブラリ(pip install soundfile)を通じて行います。 配列をinput_valuesに整えるには、パディングとtorch.FloatTensor型への変換のために AutoProcessor を使用してください。詳細は VibeVoiceAsrProcessor.call() を参照してください。 - padding_mask (
torch.BoolTensor、shape(batch_size, sequence_length)、任意) — padding の feature index に対して操作を実行しないようにするためのマスクです。 - sample (
bool、省略可能、デフォルトはTrue) — 元のモデルと同様に、音響潜在変数にガウスノイズを追加するかどうかを指定します(σ-VAE: ノイズのスケールはバッチ内の各項目に対して N(0,vae_std) からサンプリングされます)。False の場合、エンコーダーの出力がそのまま使用されるため、出力は決定論的になります。
戻り値
VibeVoiceAsrModelOutputWithPast または tuple(torch.FloatTensor)
VibeVoiceAsrModelOutputWithPast または、torch.FloatTensor のタプル(return_dict=False が渡された場合、または config.return_dict=False の場合)。設定(VibeVoiceAsrConfig)や入力に応じて、さまざまな要素で構成されます。
VibeVoiceAsrModelのforwardメソッドは、__call__特殊メソッドをオーバーライドします。
この関数内でフォワードパスの手順を定義する必要がありますが、その後、この関数ではなく
Moduleインスタンスを呼び出すべきです。前者は前処理と後処理の実行を適切に処理するのに対し、後者はそれらを黙って無視するためです。
last_hidden_state (
torch.FloatTensor、shape(batch_size, sequence_length, hidden_size)) — モデルの最終層の出力における隠れ状態のシーケンス。past_key_valuesが使用されている場合、出力されるのは、形状(batch_size, 1, hidden_size)のシーケンスの最後の隠れ状態のみです。past_key_values (
Cache、任意、use_cache=Trueが渡された場合またはconfig.use_cache=Trueの場合に返されます)— Cache のインスタンスです。hidden_states (
tuple(torch.FloatTensor)、optional、output_hidden_states=Trueが渡された場合またはconfig.output_hidden_states=Trueの場合に返されます)—torch.FloatTensorのタプル(埋め込み層を持つモデルの場合、埋め込みの出力が 1 つ、各層の出力がそれぞれ 1 つずつ)で、形状は(batch_size, sequence_length, hidden_size)です。各層の出力におけるモデルのHidden-states、および任意の初期埋め込み出力。
attentions (
tuple(torch.FloatTensor)、optional、output_attentions=Trueが渡された場合またはconfig.output_attentions=Trueの場合に返されます)—torch.FloatTensorのタプル(各レイヤーごとに1つ)、形状は(batch_size, num_heads, sequence_length, sequence_length)。アテンションのsoftmax後のアテンション重み。自己アテンションヘッド内で加重平均を計算するために使用されます。
audio_hidden_states (
torch.FloatTensor、任意) — 投影されたオーディオの隠れ状態。
VibeVoiceAsrForConditionalGeneration
クラス transformers.VibeVoiceAsrForConditionalGeneration
< source >( config: VibeVoiceAsrConfig )
パラメータ
- config (VibeVoiceAsrConfig) — モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、from_pretrained() メソッドを参照してください。
事前学習済みの音響トークナイザーと言語モデルを備えたVibeVoice ASRモデル。
このモデルは PreTrainedModel を継承しています。すべてのモデルに実装されている汎用的なメソッド(ダウンロードや保存、入力埋め込みのリサイズ、ヘッドのプルーニングなど)については、スーパークラスのドキュメントを参照してください。
このモデルは、PyTorchのtorch.nn.Moduleのサブクラスでもあります。 通常のPyTorch Moduleとして使用し、一般的な使用方法や動作に関する詳細については、PyTorchのドキュメントを参照してください。
forward
< source >( input_ids: typing.Optional[torch.LongTensor] = Noneattention_mask: typing.Optional[torch.Tensor] = Nonepast_key_values: transformers.cache_utils.Cache | None = Noneinputs_embeds: typing.Optional[torch.FloatTensor] = Noneinput_values: typing.Optional[torch.FloatTensor] = Nonepadding_mask: typing.Optional[torch.BoolTensor] = Nonelabels: typing.Optional[torch.LongTensor] = Nonelogits_to_keep: typing.Union[int, torch.Tensor] = 0sample: bool = True**kwargs: *<class 'transformers.utils.generic.TransformersKwargs'> ) → VibeVoiceAsrCausalLMOutputWithPast or tuple(torch.FloatTensor)
パラメータ
- input_ids (
torch.LongTensorの形状(batch_size, sequence_length), 、省略可) — 語彙における入力シーケンスのトークンインデックスです。デフォルトではパディングは無視されます。インデックスはAutoTokenizerを使用して取得できます。詳細については、PreTrainedTokenizer.encode()およびPreTrainedTokenizer.call()を参照してください。
- attention_mask (
torch.Tensorの形状(batch_size, sequence_length), 、任意) — パディングトークンのインデックスに対するアテンションを回避するためのマスク。[0, 1]:- マスクされていないトークンに対して1
- マスクされたトークンに対しては 0 です。
- past_key_values (
~cache_utils.Cache, 省略可) — 逐次デコードを高速化するために使用できる、事前計算された隠れ状態(自己アテンションブロックおよびクロスアテンションブロックのキーとバリュー)。通常、これはデコードの以前の段階でモデルが返したpast_key_valuesであり、use_cache=Trueまたはconfig.use_cache=True.入力として許可されるのは Cache インスタンスのみです。kv cache ガイドを参照してください。
past_key_valuesが渡されない場合、デフォルトで DynamicCache が初期化されます。モデルは、入力として与えられたのと同じキャッシュ形式を出力します。
past_key_valuesを使用する場合、すべてのinput_ids(形状(batch_size, sequence_length))ではなく、このモデルに過去のキー・バリュー状態が与えられていない未処理のinput_ids(形状(batch_size, unprocessed_length))のみを入力することになります。 - inputs_embeds (
torch.FloatTensor、形状(batch_size, sequence_length, hidden_size)、任意) —input_idsを渡す代わりに、埋め込み表現を直接渡すこともできます。これは、モデル内部の埋め込みルックアップ行列よりも、input_idsのインデックスを対応するベクトルに変換する方法をより細かく制御したい場合に有用です。 - input_values (
torch.FloatTensor、shape(batch_size, sequence_length)、任意) — 入力生の音声波形の浮動小数点値。値は、.flacまたは.wav形式のオーディオファイルをlist[float]、numpy.ndarray、またはtorch.Tensor型の配列として読み込むことで取得できます。例えば、torchcodec ライブラリ(pip install torchcodec)や soundfile ライブラリ(pip install soundfile)を通じて行います。 配列をinput_valuesに整えるには、パディングとtorch.FloatTensor型への変換のために AutoProcessor を使用してください。詳細は VibeVoiceAsrProcessor.call() を参照してください。 - padding_mask (
torch.BoolTensor、shape(batch_size, sequence_length)、任意) — padding の feature index に対して操作を実行しないようにするためのマスクです。 - labels (
torch.LongTensor、shape(batch_size, sequence_length)、任意) — マスク言語モデリング損失を計算するためのラベルです。インデックスは[0, ..., config.vocab_size]の範囲内であるか、-100 である必要があります(input_idsの docstring を参照)。インデックスが-100に設定されたトークンは無視(マスク)され、損失は[0, ..., config.vocab_size]の範囲内のラベルを持つトークンに対してのみ計算されます。 - logits_to_keep (
Union[int, torch.Tensor]、省略可、デフォルトは0) —intの場合、最後のlogits_to_keepトークンについて logits を計算します。0の場合、すべてのinput_idsについて logits を計算します(特殊ケース)。生成には最後のトークンの logits だけで十分であり、そのトークンのみについて計算することでメモリを節約できます。これは、長いシーケンスや大規模な語彙サイズの場合に特に顕著な効果があります。torch.Tensorの場合、シーケンス長次元で保持するインデックスに対応する 1 次元テンソルである必要があります。これは、パックされたテンソル形式(バッチとシーケンス長を単一の次元にまとめた形式)を使用する場合に有用です。 - sample (
bool、省略可能、デフォルトはTrue) — 元のモデルと同様に、音響潜在変数にガウスノイズを追加するかどうかを指定します(σ-VAE: ノイズのスケールはバッチ内の各項目に対して N(0,vae_std) からサンプリングされます)。False の場合、エンコーダーの出力がそのまま使用されるため、出力は決定論的になります。
戻り値
VibeVoiceAsrCausalLMOutputWithPast または tuple(torch.FloatTensor)
VibeVoiceAsrCausalLMOutputWithPast または、return_dict=False が渡された場合、または config.return_dict=False の場合に torch.FloatTensor のタプル。設定 (VibeVoiceAsrConfig) や入力に応じて、さまざまな要素で構成されます。
VibeVoiceAsrForConditionalGenerationのforwardメソッドは、__call__特殊メソッドをオーバーライドします。
この関数内でフォワードパスの手順を定義する必要がありますが、その後、この関数ではなく
Moduleインスタンスを呼び出すべきです。前者は前処理と後処理の実行を適切に処理するのに対し、後者はそれらを黙って無視するためです。
loss (
torch.FloatTensor、shape(1,)、optional、labelsが指定された場合に返されます)— 言語モデリングの損失。logits (
torch.FloatTensor、shape(batch_size, sequence_length, config.vocab_size)) — 予測スコア。past_key_values (
Cache、任意) — Cache インスタンス。hidden_states (
tuple[torch.FloatTensor]、optional、output_hidden_states=Trueが渡された場合またはconfig.output_hidden_states=Trueの場合に返される) —torch.FloatTensorのタプル(埋め込み層を持つモデルの場合、埋め込みの出力用が 1 つ、各層の出力用が 1 つずつ)で、形状は(batch_size, sequence_length, hidden_size)です。各層の出力におけるモデルのHidden-states、および任意の初期埋め込み出力。
attentions (
tuple[torch.FloatTensor]、optional、output_attentions=Trueが渡された場合またはconfig.output_attentions=Trueの場合に返されます) —torch.FloatTensorのタプル(各レイヤーごとに1つ)、形状は(batch_size, num_heads, sequence_length, sequence_length)。アテンションのsoftmax後のアテンション重み。自己アテンションヘッド内で加重平均を計算するために使用されます。
audio_hidden_states (
torch.FloatTensor、任意) — 投影されたオーディオの隠れ状態。