# VibeVoice

## 概要

[VibeVoice](https://huggingface.co/papers/2508.19205)は、Large Language Model (LLM) の構造内で next-token diffusion アプローチを採用することで、複数話者の高忠実度・長尺音声の合成を実現する新しいフレームワークです。本質的な会話の「雰囲気」を捉えるよう設計されており、ポッドキャストや複数参加者のオーディオブックなどの音声コンテンツの生成に特に適しています。

2つのモデルチェックポイントが以下の場所で利用可能です:
- [vibevoice/VibeVoice-1.5B-hf](https://huggingface.co/vibevoice/VibeVoice-1.5B-hf)
- [vibevoice/VibeVoice-7B-hf](https://huggingface.co/vibevoice/VibeVoice-7B-hf)

このモデルは[Eric Bezzam](https://huggingface.co/bezzam)によって提供されました。

## アーキテクチャ

    

VibeVoice フレームワークは、3 つの主要なコンポーネントを統合しています:
1. **連続音声トークナイザ:** 専用の[音響](./vibevoice_acoustic_tokenizer)トークナイザとセマンティックトークナイザ。音響トークナイザは $\sigma$-VAE を用いて超低圧縮（7.5 トークン/秒、3200 倍）を実現し、スケーラビリティと忠実性を確保します。一方、セマンティックトークナイザは ASR プロキシタスクを用いて、内容中心の特徴抽出を行います。
2. **大規模言語モデル（LLM）:** コアとなるシーケンスモデルとして、Qwen2.5（1.5Bおよび7Bのバージョン）を使用します。
3. **トークンレベルの拡散ヘッド:** LLMの隠れ状態を条件とし、ストリーミング方式で連続的なVAE特徴を予測する役割を担います。

元のVibeVoice-1.5Bチェックポイントは、Hugging Face上の[Microsoft](https://huggingface.co/microsoft/VibeVoice-1.5B)組織で利用可能です。

## 主な機能

- **長文合成**：最大90分間の複数話者による会話音声の合成が可能です。
- **マルチスピーカー対話**: 最大4人のスピーカーを含むオーディオを合成できます。
- **最先端の品質**: 主観的指標および客観的指標の両方で、ベースラインを上回る性能を発揮します。
- **高圧縮**: 7.5 Hz という超低フレームレートで動作する新しい音声トークナイザーにより実現されています。
- **スケーラブルなLLM**: コアとなるLLMを1.5Bから7Bにスケールさせることで、知覚品質が大幅に向上します。

## 使用方法

### セットアップ 

音声生成は拡散プロセスに依存するため、ノイズスケジューラーが必要です。最も簡単なアプローチ（モデル開発者が採用している方法）は、`diffusers` ライブラリのノイズスケジューラーを使用することです。デフォルトでは、モデルは内部で `diffusers` を使用してノイズスケジューラーを作成します。
```
pip install diffusers
pip install soundfile   # for saving audio
```

### モデルの読み込み

```python
from transformers import AutoProcessor, AutoModelForTextToWaveform

model_id = "vibevoice/VibeVoice-1.5B-hf"  # "vibevoice/VibeVoice-7B-hf"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForTextToWaveform.from_pretrained(model_id)
```

### テキストから音声への変換（TTS）

```python
import os
from transformers import AutoProcessor, AutoModelForTextToWaveform

model_id = "vibevoice/VibeVoice-1.5B-hf"   # "vibevoice/VibeVoice-7B-hf"
text = "Hello, nice to meet you. How are you?"

# Load model
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForTextToWaveform.from_pretrained(model_id, device_map="auto")

# Prepare input
conversation = [{"role": "0", "content": [{"type": "text", "text": text}]}]
inputs = processor.apply_chat_template(
    conversation, return_dict=True, tokenize=True, add_generation_prompt=True,
).to(model.device, model.dtype)

# Generate!
audio = model.generate(**inputs)

# Save to file
file_name = f"{os.path.basename(model_id)}_tts.wav"
processor.save_audio(audio, file_name)
print(f"Saved output to {file_name}")
```

### TTS音声クローニング

参照音声をテキストとともにチャットテンプレートの辞書に含めることで、ボイスのクローニングを行うことができます。

```python
import os
from transformers import AutoProcessor, AutoModelForTextToWaveform, set_seed

model_id = "vibevoice/VibeVoice-1.5B-hf"   # "vibevoice/VibeVoice-7B-hf"
text = "Hello, nice to meet you. How are you?"
set_seed(42)  # for deterministic results

# Load model
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForTextToWaveform.from_pretrained(model_id, device_map="auto")
sampling_rate = processor.feature_extractor.sampling_rate

# Prepare input
conversation = [
    {
        "role": "0",
        "content": [
            {"type": "text", "text": text},
            {
                "type": "audio",
                "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/voices/en-Alice_woman.wav",
            },
        ],
    }
]
inputs = processor.apply_chat_template(
    conversation, return_dict=True, tokenize=True, add_generation_prompt=True,
).to(model.device, model.dtype)

# Generate!
audio = model.generate(**inputs)

# Save to file
fn = f"{os.path.basename(model_id)}_tts_clone.wav"
processor.save_audio(audio, fn)
print(f"Saved output to {fn}")
```

### スクリプトからポッドキャストを生成する

…以下は、チャットテンプレート内の各一意のロールIDに対して参照オーディオを提供することで、それぞれの声声をクローンし、2人の話者間の会話を生成する例です。

以下の例では、生成の進捗を追跡するために`monitor_progress`オプションも使用しています。

```python
import os
import time
from transformers import AutoProcessor, AutoModelForTextToWaveform

model_id = "vibevoice/VibeVoice-1.5B-hf"   # "vibevoice/VibeVoice-7B-hf"
max_new_tokens = 400  # `None` to ensure full generation

# create conversation with an audio for the first time a speaker appears to clone that particular voice
conversation = [
    {
        "role": "0",
        "content": [
            {
                "type": "text", "text": "Hello everyone, and welcome to the VibeVoice podcast. I'm your host, Linda, 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 Thomas here to talk about it with me.",
            },
            {
                "type": "audio", "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/voices/en-Alice_woman.wav",
            },
        ],
    },
    {
        "role": "1",
        "content": [
            {
                "type": "text", "text": "Thanks so much for having me, Linda. You're absolutely right—this question always brings out some seriously strong feelings.",
            },
            {
                "type": "audio", "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/voices/en-Frank_man.wav",
            },
        ],
    },
    {
        "role": "0",
        "content": [
            {
                "type": "text", "text": "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.",
            },
        ],
    },
    {
        "role": "1",
        "content": [
            {
                "type": "text", "text": "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",
            },
        ],
    },
]

# Load model
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForTextToWaveform.from_pretrained(model_id, device_map="auto")

# prepare inputs
inputs = processor.apply_chat_template(
    conversation, return_dict=True, tokenize=True, add_generation_prompt=True,
).to(model.device, model.dtype)

# Generate audio with a progress bar to track generation
model.generation_config.max_new_tokens = max_new_tokens
start_time = time.time()
audio = model.generate(**inputs, monitor_progress=True)
generation_time = time.time() - start_time
print(f"Generation time: {generation_time:.2f} seconds")

# Save audio
fn = f"{os.path.basename(model_id)}_script.wav"
processor.save_audio(audio, fn)
print(f"Saved output to {fn}")
```

### バッチ推論

バッチ処理では、会話のリストを`processor.apply_chat_template`に渡すことができます:

```python
import os
import time
from transformers import AutoProcessor, AutoModelForTextToWaveform

model_id = "vibevoice/VibeVoice-1.5B-hf"   # "vibevoice/VibeVoice-7B-hf"
max_new_tokens = 400  # `None` to ensure full generation

conversation = [
    [
        {
            "role": "0",
            "content": [
                {
                    "type": "text", "text": "Hello everyone, and welcome to the VibeVoice podcast. I'm your host, Linda, 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 Thomas here to talk about it with me.",
                },
                {
                    "type": "audio",
                    "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/voices/en-Alice_woman.wav",
                },
            ],
        },
        {
            "role": "1",
            "content": [
                {
                    "type": "text", "text": "Thanks so much for having me, Linda.",
                },
                {
                    "type": "audio", "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/voices/en-Frank_man.wav",
                },
            ],
        },
    ],
    [
        {
            "role": "0",
            "content": [
                {
                    "type": "text", "text": "Hello and welcome to Planet in Peril. I'm your host, Alice. We're here today to discuss a really sobering new report that looks back at the last ten years of climate change. I'm joined by our expert panel. Welcome Carter, Frank, and Maya.",
                },
                {
                    "type": "audio", "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/voices/en-Alice_woman.wav",
                },
            ],
        },
        {
            "role": "1",
            "content": [
                {"type": "text", "text": "Hi Alice, it's great to be here. I'm Carter."},
                {
                    "type": "audio", "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/voices/en-Carter_man.wav",
                },
            ],
        },
        {
            "role": "2",
            "content": [
                {"type": "text", "text": "Hello, uh, I'm Frank. Good to be on."},
                {
                    "type": "audio", "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/voices/en-Frank_man.wav",
                },
            ],
        },
        {
            "role": "3",
            "content": [
                {"type": "text", "text": "And I'm Maya. Thanks for having me."},
                {
                    "type": "audio", "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/voices/en-Maya_woman.wav",
                },
            ],
        },
    ],
]

# Load model
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForTextToWaveform.from_pretrained(model_id, device_map="auto")

# prepare inputs
inputs = processor.apply_chat_template(
    conversation, return_dict=True, tokenize=True, add_generation_prompt=True,
).to(model.device, model.dtype)

# Generate audio with a progress bar to track generation
model.generation_config.max_new_tokens = max_new_tokens
start_time = time.time()
audio = model.generate(**inputs, monitor_progress=True)
generation_time = time.time() - start_time
print(f"Generation time: {generation_time:.2f} seconds")

# Save audio
output_dir = f"{os.path.basename(model_id)}_batch"
processor.save_audio(audio, output_dir)
print(f"Saved output to {output_dir}")
```

### Pipelineの使用方法

VibeVoice はパイプラインとして読み込むこともできます。以下では、拡散パラメータを調整する方法も示します。

```python
import os
import soundfile as sf
from transformers import pipeline

model_id = "vibevoice/VibeVoice-1.5B-hf"   # "vibevoice/VibeVoice-7B-hf"
text = "Hello, nice to meet you. How are you?"
pipe = pipeline("text-to-speech", model=model_id)

# Generate!
conversation = [
    {
        "role": "0",
        "content": [
            {"type": "text", "text": text},
            {
                "type": "audio", "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/voices/en-Alice_woman.wav",
            },
        ],
    }
]
# optional kwargs for generation
generate_kwargs = {"guidance_scale": 1.3, "num_diffusion_steps": 10}
output = pipe(conversation, generate_kwargs=generate_kwargs)

# Save to file
fn = f"{os.path.basename(model_id)}_pipeline.wav"
sf.write(fn, output["audio"], output["sampling_rate"])
print(f"Saved output to {fn}")
```

### トレーニング

VibeVoiceは、モデルが出力する損失で学習できます。

```python
from transformers import AutoProcessor, AutoModelForTextToWaveform

model_id = "vibevoice/VibeVoice-1.5B-hf"   # "vibevoice/VibeVoice-7B-hf"

# Load model and processor
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForTextToWaveform.from_pretrained(
    model_id,
    diffusion_loss_weight=0.75,  # by default, equal weighting (0.5) of language modeling loss (CE) and diffusion loss is applied
    device_map="auto"
)
model.train()

# Prepare batch of 2
conversation = [
    [
        {
            "role": "0",
            "content": [
                {
                    "type": "text", "text": "VibeVoice is this novel framework designed for generating expressive, long-form, multi-speaker, conversational audio.",
                },
                {
                    "type": "audio", "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/realtime_model/vibevoice_tts_german.wav",
                },
            ],
        }
    ],
    # NOTE: multiple speakers not supported yet
    [
        {
            "role": "0",
            "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",
                    "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/example_output/VibeVoice-1.5B_output.wav",
                },
            ],
        }
    ],
]

# Process with apply_chat_template and output_labels=True for training
inputs = processor.apply_chat_template(
    conversation,
    tokenize=True,
    return_dict=True,
    processor_kwargs={"output_labels": True},
).to(model.device, model.dtype)

# Forward pass
outputs = model(**inputs, ddpm_batch_multiplier=2, num_diffusion_steps=2)
print(f"Total loss: {outputs.loss.item():.4f}")

# Backward pass
outputs.loss.backward()
```

### Torch compile

モデルは`torch.compile`でコンパイルすることで、より高速な推論を行うことができます。コンパイル済みモデルが最大速度に達するには、数回のウォームアップ実行が必要です。

A100でバッチサイズ4の場合、コンパイル済み推論とコンパイルなし推論の間で約1.5倍の高速化を確認しました。[このスクリプト](https://gist.github.com/ebezzam/c45b9fdee65f3029e17d566e30c59399)を参照してください。

```python
import os
import time
import torch
from transformers import AutoModelForTextToWaveform, AutoProcessor, CompileConfig

model_id = "vibevoice/VibeVoice-1.5B-hf"   # "vibevoice/VibeVoice-7B-hf"
num_warmup = 5
max_new_tokens = 128

torch.set_float32_matmul_precision("high")

# Load processor + model
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForTextToWaveform.from_pretrained(model_id, dtype=torch.bfloat16, device_map="auto").eval()

# Prepare inputs
conversation = [
    [
        {
            "role": "0",
            "content": [
                {"type": "text", "text": "VibeVoice is a novel framework for generating expressive audio."},
                {
                    "type": "audio", "url": "https://huggingface.co/datasets/bezzam/vibevoice_samples/resolve/main/realtime_model/vibevoice_tts_german.wav",
                },
            ],
        }
    ],
] * 4  # batch size 4
inputs = processor.apply_chat_template(
    conversation, tokenize=True, return_dict=True, add_generation_prompt=True,
).to(model.device, model.dtype)

compile_config = CompileConfig(mode="default", dynamic=False)

generate_kwargs = dict(
    **inputs,
    max_new_tokens=max_new_tokens,
    cache_implementation="static",
    compile_config=compile_config,
)

# Warmup
print("Warming up...")
warmup_start = time.time()
with torch.inference_mode():
    for _ in range(num_warmup):
        torch.compiler.cudagraph_mark_step_begin()
        _ = model.generate(**generate_kwargs)
torch.cuda.synchronize()
print(f"Warmup complete in {time.time() - warmup_start:.2f}s. Ready!")

# Apply model
with torch.inference_mode():
    torch.compiler.cudagraph_mark_step_begin()
    audio = model.generate(**generate_kwargs)
output_folder = f"{os.path.basename(model_id)}_compiled_output"
processor.save_audio(audio, output_folder)
print(f"Saved output to {output_folder}")
```

## VibeVoiceConfig[[transformers.VibeVoiceConfig]]

#### transformers.VibeVoiceConfig[[transformers.VibeVoiceConfig]]

```python
transformers.VibeVoiceConfig(transformers_version: str | None = None, architectures: list[str] | None = None, output_hidden_states: bool | None = False, return_dict: bool | None = True, dtype: str | torch.dtype | None = None, chunk_size_feed_forward: int = 0, is_encoder_decoder: bool = False, id2label: dict[int, str] | dict[str, str] | None = None, label2id: dict[str, int] | dict[str, str] | None = None, problem_type: Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None, audio_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None, semantic_model_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None, text_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None, diffusion_head_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None, pad_token_id: int = 151643, eos_token_id: int = 151643, audio_bos_token_id: int = 151652, audio_eos_token_id: int = 151653, audio_token_id: int = 151654, diffusion_loss_weight: float = 0.5)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice/configuration_vibevoice.py#L49)

**パラメータ:**

audio_config (`Union[dict, ~configuration_utils.PreTrainedConfig]`, *任意*) : 音声バックボーンの config オブジェクトまたは辞書。

semantic_model_config (`Union[AutoConfig, dict]`, *任意*) : セマンティック トークナイザー エンコーダーの config オブジェクトまたは辞書。このトークナイザーは音声からセマンティックな特徴を抽出します。

text_config (`Union[dict, ~configuration_utils.PreTrainedConfig]`, *任意*) : テキストバックボーンの config オブジェクトまたは辞書。

diffusion_head_config (`Union[VibeVoiceDiffusionHeadConfig, dict]`、*optional*) : 音響潜在変数の合成に使用される拡散ヘッドの設定オブジェクトまたは辞書です。

pad_token_id (`int`、*任意*、デフォルトは`151643`) : 語彙内でパディングに使用されるトークン ID。

eos_token_id (`int`, *任意*, デフォルトは `151643`) : 語彙内でストリーム終了に使用されるトークンID。

audio_bos_token_id (`int`, *optional*, デフォルトは 151652) : 音声トークンの開始を示すトークン ID。

audio_eos_token_id (`int`、*optional*、デフォルトは 151653) : 音声トークンの終了を示すトークン ID。

audio_token_id (`int`、*任意*、デフォルトは`151654`) : 入力音声のプレースホルダーとして使用されるオーディオトークンのインデックス。

diffusion_loss_weight (`float`、*optional*、デフォルト値は 0.5) : 全体の損失計算における拡散損失の重みです。言語モデリングヘッドのクロスエントロピー損失は、`(1 - diffusion_loss_weight)` で重み付けされます。

これは、VibeVoiceForConditionalGeneration の設定を保存するための設定クラスです。指定された引数に基づいて Vibevoice モデルをインスタンス化し、モデルのアーキテクチャを定義するために使用されます。デフォルト値で設定をインスタンス化すると、[vibevoice/VibeVoice-1.5B-hf](https://huggingface.co/vibevoice/VibeVoice-1.5B-hf) と同様の設定が得られます。

設定オブジェクトは [PreTrainedConfig](/docs/transformers/main/ja/main_classes/configuration#transformers.PreTrainedConfig) を継承し、モデルの出力を制御するために使用できます。詳細については、[PreTrainedConfig](/docs/transformers/main/ja/main_classes/configuration#transformers.PreTrainedConfig) のドキュメントを参照してください。

```python
>>> from transformers import VibeVoiceForConditionalGeneration, VibeVoiceConfig

>>> # Initializing a VibeVoice configuration
>>> configuration = VibeVoiceConfig()

>>> # Initializing a 1.5B model with random weights
>>> model = VibeVoiceForConditionalGeneration(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```

## VibeVoiceDiffusionHeadConfig[[transformers.VibeVoiceDiffusionHeadConfig]]

#### transformers.VibeVoiceDiffusionHeadConfig[[transformers.VibeVoiceDiffusionHeadConfig]]

```python
transformers.VibeVoiceDiffusionHeadConfig(transformers_version: str | None = None, architectures: list[str] | None = None, output_hidden_states: bool | None = False, return_dict: bool | None = True, dtype: str | torch.dtype | None = None, chunk_size_feed_forward: int = 0, is_encoder_decoder: bool = False, id2label: dict[int, str] | dict[str, str] | None = None, label2id: dict[str, int] | dict[str, str] | None = None, problem_type: Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None, hidden_size: int = 1536, latent_size: int = 64, num_hidden_layers: int = 4, intermediate_size: int = 4608, rms_norm_eps: float = 1e-05, hidden_act: str = 'silu', frequency_embedding_size: int = 256, diffusion_max_period: int = 10000, mlp_bias: bool = False)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice/configuration_vibevoice.py#L24)

**パラメータ:**

hidden_size (`int`、*任意*、デフォルトは`1536`) : 隠れ表現の次元数。

latent_size (`int`, *optional*, デフォルトは 64) : ヘッドがノイズ除去を行う音響潜在変数の次元数。

num_hidden_layers (`int`、*任意*、デフォルトは `4`) : Transformer デコーダーの隠れ層の数。

intermediate_size (`int`、*optional*、デフォルトは`4608`) : MLP表現の次元数。

rms_norm_eps (`float`、*任意*、デフォルトは`1e-05`) : rms 正規化レイヤーで使用する epsilon。

hidden_act (`str`、*任意*、デフォルトは`silu`) : デコーダーで使用する非線形活性化関数（関数または文字列）。例えば、`"gelu"`、`"relu"`、`"silu"`など。

frequency_embedding_size (`int`、*optional*、デフォルトは 256) : diffusion head における timestep 符号化用の正弦波周波数埋め込みのサイズです。

diffusion_max_period (`int`、*optional*、デフォルトは 10000) : diffusion head における正弦波周波数埋め込みの最大周期です。

mlp_bias (`bool`, *任意*, デフォルトは `False`) : MLP 層の up_proj、down_proj、gate_proj 層でバイアスを使用するかどうか。

これは、VibeVoiceForConditionalGeneration の設定を保存するための設定クラスです。指定された引数に基づいて Vibevoice モデルをインスタンス化し、モデルのアーキテクチャを定義するために使用されます。デフォルト値で設定をインスタンス化すると、[vibevoice/VibeVoice-1.5B-hf](https://huggingface.co/vibevoice/VibeVoice-1.5B-hf) と同様の設定が得られます。

設定オブジェクトは [PreTrainedConfig](/docs/transformers/main/ja/main_classes/configuration#transformers.PreTrainedConfig) を継承し、モデルの出力を制御するために使用できます。詳細については、[PreTrainedConfig](/docs/transformers/main/ja/main_classes/configuration#transformers.PreTrainedConfig) のドキュメントを参照してください。

## VibeVoiceProcessor[[transformers.VibeVoiceProcessor]]

#### transformers.VibeVoiceProcessor[[transformers.VibeVoiceProcessor]]

```python
transformers.VibeVoiceProcessor(feature_extractor, tokenizer, chat_template = None, audio_bos_token = '<|vision_start|>', audio_eos_token = '<|vision_end|>', audio_token = '<|vision_pad|>')
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice/processing_vibevoice.py#L46)

**パラメータ:**

feature_extractor (`VibeVoiceAcousticTokenizerFeatureExtractor`) : 特徴抽出器は必須の入力です。

tokenizer (`Qwen2TokenizerFast`) : トークナイザーは必須の入力です。

chat_template (`str`) : チャット内のメッセージのリストをトークン化可能な文字列に変換するための Jinja テンプレート。

audio_bos_token (`str`、*任意*、デフォルトは`"<|vision_start|>"`) : 音声生成の開始を示すために使用されるトークン。

audio_eos_token (`str`、*任意*、デフォルトは`"<|vision_end|>"`) : 音声生成の終了を示すために使用されるトークン。

audio_token (`str`、*任意*、デフォルトは`"<|vision_pad|>"`) : 音声の生成を継続することを示すために使用されるトークン。

VibeVoiceProcessorを構築します。これは、フィーチャーエクストラクターとトークナイザーを単一のプロセッサーにラップします。

[VibeVoiceProcessor](/docs/transformers/main/ja/model_doc/vibevoice#transformers.VibeVoiceProcessor) は、[VibeVoiceAcousticTokenizerFeatureExtractor](/docs/transformers/main/ja/model_doc/vibevoice_acoustic_tokenizer#transformers.VibeVoiceAcousticTokenizerFeatureExtractor) と [Qwen2TokenizerFast](/docs/transformers/main/ja/model_doc/qwen2#transformers.Qwen2Tokenizer) のすべての機能を提供します。詳細については、[~VibeVoiceAcousticTokenizerFeatureExtractor](/docs/transformers/main/ja/model_doc/vibevoice_acoustic_tokenizer#transformers.VibeVoiceAcousticTokenizerFeatureExtractor) および [~Qwen2TokenizerFast](/docs/transformers/main/ja/model_doc/qwen2#transformers.Qwen2Tokenizer) を参照してください。

#### __call__[[transformers.VibeVoiceProcessor.__call__]]

```python
__call__(text: str | list[str] | list[list[str]], audio: typing.Union[numpy.ndarray, ForwardRef('torch.Tensor'), collections.abc.Sequence[numpy.ndarray], collections.abc.Sequence['torch.Tensor'], NoneType] = None, output_labels: bool | None = False, **kwargs: *<class 'transformers.models.vibevoice.processing_vibevoice.VibeVoiceProcessorKwargs'>)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice/processing_vibevoice.py#L98)

**パラメータ:**

text (`str`, `List[str]`) : 処理する入力テキスト。通常、音声トークンのプレースホルダーを含む形で、apply_chat_template によって準備されます。

audio (`List[Union[str, np.ndarray]]`、*optional*) : スピーカーのボイスクローニング用のオーディオサンプルです。テキスト内のオーディオトークンプレースホルダーの数と一致する必要があります。

output_labels (`bool`、*任意*、デフォルト: False) : 学習用のラベルを返すかどうか。

- ****kwargs** : トークナイザーとフィーチャーエクストラクターに渡される追加のキーワード引数。

return_tensors (`str` または [TensorType](/docs/transformers/main/ja/internal/file_utils#transformers.TensorType)、*optional*) : 設定されている場合、特定のフレームワークのテンソルを返します。受け入れ可能な値は以下の通りです:  - `'pt'`: PyTorch の `torch.Tensor` オブジェクトを返します。 - `'np'`: NumPy の `np.ndarray` オブジェクトを返します。

- ****kwargs** ([ProcessingKwargs](/docs/transformers/main/ja/main_classes/processors#transformers.ProcessingKwargs), *optional*) : 各モダリティ（テキスト、画像、動画、音声）の追加処理オプション。モデル固有のパラメータは上記にリストされています。サポートされている引数の完全なリストについては、TypedDict クラスを参照してください。

**戻り値:** [BatchFeature](/docs/transformers/main/ja/main_classes/feature_extractor#transformers.BatchFeature)

以下のフィールドを持つ[BatchFeature](/docs/transformers/main/ja/main_classes/feature_extractor#transformers.BatchFeature):
- **input_ids** -- モデルに与えるトークンIDのリスト。
- **attention_mask** -- モデルがどのトークンに注意すべきかを指定するインデックスのリスト（`return_attention_mask=True`の場合）。
- **input_values** -- モデルに与える音声値のリスト。`audio` が `None` でない場合に返されます。
- **padding_mask** -- モデルがどの音声フレームに注意すべきかを指定するインデックスのリスト。`audio`が`None`でない場合に返されます。
- **labels** -- 言語モデルの学習用のラベルです。パディングおよびオーディオ拡散トークンは -100 でマスクされます（オーディオ拡散トークンの埋め込みはオーディオ特徴量に置き換えられるため、そのトークン ID は意味のあるターゲットではありません）。オーディオの bos/eos トークンとテキストの eos トークンはターゲットとして保持され、LM がオーディオの生成を開始・停止するタイミングを学習できるようにします。`output_labels=True` の場合に返されます。
- **acoustic_loss_mask** -- 拡散損失を計算する位置のブールマスク。音声拡散トークンの位置で True になります。`output_labels=True` の場合に返されます。

## VibeVoiceForConditionalGeneration[[transformers.VibeVoiceForConditionalGeneration]]

#### transformers.VibeVoiceForConditionalGeneration[[transformers.VibeVoiceForConditionalGeneration]]

```python
transformers.VibeVoiceForConditionalGeneration(config: VibeVoiceConfig)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice/modeling_vibevoice.py#L365)

**パラメータ:**

config ([VibeVoiceConfig](/docs/transformers/main/ja/model_doc/vibevoice#transformers.VibeVoiceConfig)) : モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、[from_pretrained()](/docs/transformers/main/ja/main_classes/model#transformers.PreTrainedModel.from_pretrained) メソッドを確認してください。

言語モデル、オーディオトークナイザー、コネクタ、拡散ヘッドで構成されるVibeVoiceモデル。

このモデルは [PreTrainedModel](/docs/transformers/main/ja/main_classes/model#transformers.PreTrainedModel) を継承しています。ライブラリがすべてのモデルに対して実装している汎用的なメソッド（ダウンロードや保存、入力埋め込みのリサイズ、ヘッドのプルーニングなど）については、スーパークラスのドキュメントを参照してください。

このモデルは、PyTorchの[torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module)のサブクラスでもあります。通常のPyTorch Moduleとして使用し、一般的な使用方法や動作に関する詳細については、PyTorchのドキュメントを参照してください。

#### forward[[transformers.VibeVoiceForConditionalGeneration.forward]]

```python
forward(input_ids: LongTensor = None, inputs_embeds: typing.Optional[torch.Tensor] = None, labels: typing.Optional[torch.LongTensor] = None, logits_to_keep: int | slice = 0, input_values: typing.Optional[torch.Tensor] = None, padding_mask: typing.Optional[torch.BoolTensor] = None, acoustic_loss_mask: typing.Optional[torch.BoolTensor] = None, noise_scheduler: object | None = None, ddpm_batch_multiplier: int = 4, num_diffusion_steps: int = 10, sample: bool = True, **kwargs)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice/modeling_vibevoice.py#L420)

**パラメータ:**

input_ids (`torch.LongTensor`、shape `(batch_size, sequence_length)`、*任意*) : 語彙における入力シーケンスのトークンインデックスです。デフォルトでは、パディングは無視されます。インデックスは [AutoTokenizer](/docs/transformers/main/ja/model_doc/auto#transformers.AutoTokenizer) を使用して取得できます。詳細については、[PreTrainedTokenizer.encode()](/docs/transformers/main/ja/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) および [PreTrainedTokenizer.__call__()](/docs/transformers/main/ja/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) を参照してください。 [入力IDとは何ですか？](../glossary#input-ids)

inputs_embeds (`torch.Tensor`、shape `(batch_size, sequence_length, hidden_size)`、*任意*) : `input_ids` を渡す代わりに、埋め込み表現を直接渡すこともできます。これは、モデル内部の埋め込み参照行列よりも、`input_ids` のインデックスを対応するベクトルに変換する方法をより細かく制御したい場合に有用です。

labels (`torch.LongTensor`、形状 `(batch_size, sequence_length)`、*任意*) : マスク言語モデリング損失を計算するためのラベル。インデックスは `[0, ..., config.vocab_size]` の範囲内であるか、-100 である必要があります（`input_ids` のドキュメント文字列を参照）。インデックスが `-100` に設定されたトークンは無視（マスク）され、損失は `[0, ..., config.vocab_size]` の範囲内のラベルを持つトークンに対してのみ計算されます。

logits_to_keep (`Union[int, slice]`、*任意*、デフォルトは`0`) : `int`の場合、最後の`logits_to_keep`トークンについてlogitsを計算します。`0`の場合、すべての`input_ids`についてlogitsを計算します（特殊なケース）。生成には最後のトークンのlogitsのみが必要であり、そのトークンのみを対象に計算することでメモリを節約できます。これは、長いシーケンスや大規模な語彙サイズの場合に特に顕著な効果があります。`torch.Tensor`の場合、シーケンス長次元で保持するインデックスに対応する1次元である必要があります。これは、パックされたテンソル形式（バッチとシーケンス長を単一の次元にまとめる形式）を使用する場合に有用です。

input_values (`torch.Tensor`, *任意*) : 音声クローニング用の前処理済み音声波形。

padding_mask (`torch.BoolTensor`, *任意*) : 有効な入力フレームを示すマスク。

acoustic_loss_mask (`torch.BoolTensor`, *任意*) : 特定の音響トークンのみで拡散損失を計算するためのマスク。

noise_scheduler (`object`, *任意*) : 拡散損失のノイズターゲットを計算するために学習で必要です。デフォルトでは、モデルの`generation_config`で指定されたノイズスケジューラの設定を使用します。

ddpm_batch_multiplier (`int`, *optional*, デフォルトは 4) : 学習において、拡散損失の計算のために各オーディオトークンごとに生成するノイズサンプルの数です。学習の安定化に役立ちます。

num_diffusion_steps (`int`, *任意*, デフォルトは 10) : 学習に使用する拡散ステップ数です。指定されない場合、デフォルトで 10 になります。

sample (`bool`、*任意*、デフォルトは`True`) : 元のモデルと同様に、音響潜在変数にガウスノイズを追加するかどうか（σ-VAE: ノイズのスケールはバッチ項目ごとに N(0, `vae_std`) からサンプリングされる）。False の場合、エンコーダーの出力がそのまま使用されるため、出力は決定論的になります。

**戻り値:** `VibeVoiceCausalLMOutputWithPast` または `tuple(torch.Tensor)`

`VibeVoiceCausalLMOutputWithPast`、または`torch.Tensor`のタプル（`return_dict=False`が渡された場合、または`config.return_dict=False`の場合）。設定（[VibeVoiceConfig](/docs/transformers/main/ja/model_doc/vibevoice#transformers.VibeVoiceConfig)）や入力に応じて、さまざまな要素で構成されます。

[VibeVoiceForConditionalGeneration](/docs/transformers/main/ja/model_doc/vibevoice#transformers.VibeVoiceForConditionalGeneration)のforwardメソッドは、`__call__`特殊メソッドをオーバーライドします。

この関数内でフォワードパスの手順を定義する必要がありますが、その後、この関数ではなく`Module`インスタンスを呼び出すべきです。前者は前処理と後処理の実行を適切に処理するのに対し、後者はそれらを無視してしまいます。

- **last_hidden_state** (`torch.Tensor`、形状 `(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](/docs/transformers/main/ja/internal/generation_utils#transformers.Cache) のインスタンスです。詳細については、[kv cache ガイド](https://huggingface.co/docs/transformers/en/kv_cache)を参照してください。

  自己アテンションブロック（および `config.is_encoder_decoder=True` の場合、クロスカレンションブロック）の事前計算済みヒドゥンステート（キーとバリュー）を保持します。これらは逐次デコーディングを高速化するために使用できます（`past_key_values` 入力参照）。
- **hidden_states** (`tuple(torch.Tensor)`、*optional*、`output_hidden_states=True` が渡された場合または `config.output_hidden_states=True` の場合に返されます) -- `torch.Tensor` のタプル（モデルに埋め込み層がある場合はその出力用 1 つ、各層の出力用 1 つずつ）で、形状は `(batch_size, sequence_length, hidden_size)` です。

  各層の出力におけるモデルのHidden-states、および任意の初期埋め込み出力。
- **attentions** (`tuple(torch.Tensor)`、*optional*、`output_attentions=True` が渡された場合または `config.output_attentions=True` の場合に返されます) -- `torch.Tensor` のタプル（各レイヤーごとに1つ）、形状は `(batch_size, num_heads, sequence_length, sequence_length)`。

  アテンションのsoftmax後のアテンション重み。自己アテンションヘッド内で加重平均を計算するために使用されます。
- **loss** (`torch.Tensor`、形状 `(1,)`、*任意*、`labels` が指定された場合に返されます) -- 言語モデリングの損失(次のトークンの予測用)。
- **logits** (`torch.Tensor`、形状 `(batch_size, sequence_length, config.vocab_size)`) -- 言語モデリングヘッドの予測スコア（SoftMax 適用前の各語彙トークンのスコア）。
- **audio_features** (`torch.Tensor`、形状 `(batch_size, sequence_length, feature_size)`、*任意*) -- 言語モデルの条件付けに使用できる抽出済みオーディオ特徴量。

例:

```python
>>> from transformers import AutoProcessor, VibeVoiceForConditionalGeneration

>>> model = VibeVoiceForConditionalGeneration.from_pretrained("vibevoice/VibeVoice-1.5B-hf")

>>> processor = AutoProcessor.from_pretrained("vibevoice/VibeVoice-1.5B-hf")
>>> inputs = processor(text="Hello, my dog is cute", return_tensors="pt")

>>> # generate speech
>>> speech = model(inputs["input_ids"])
```

#### generate[[transformers.VibeVoiceForConditionalGeneration.generate]]

```python
generate(inputs: typing.Optional[torch.Tensor] = None, generation_config: transformers.generation.configuration_utils.GenerationConfig | None = None, logits_processor: transformers.generation.logits_process.LogitsProcessorList | None = None, stopping_criteria: transformers.generation.stopping_criteria.StoppingCriteriaList | None = None, prefix_allowed_tokens_fn: collections.abc.Callable[[int, torch.Tensor], list[int]] | None = None, synced_gpus: bool | None = None, assistant_model: typing.Optional[ForwardRef('PreTrainedModel')] = None, streamer: typing.Optional[ForwardRef('BaseStreamer')] = None, negative_prompt_ids: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, custom_generate: str | collections.abc.Callable | None = None, **kwargs)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L2581)

**パラメータ:**

inputs (`torch.Tensor`、モダリティによって形状が異なる、*任意*) : 生成のプロンプトとして使用されるシーケンス、またはエンコーダーへのモデル入力です。`None` の場合、`bos_token_id` とバッチサイズ 1 で初期化されます。デコーダー専用モデルの場合、`inputs` は `input_ids` の形式である必要があります。エンコーダーデコーダーモデルの場合、*inputs* は `input_ids`、`input_values`、`input_features`、`pixel_values` のいずれかを表すことができます。

generation_config ([GenerationConfig](/docs/transformers/main/ja/main_classes/text_generation#transformers.GenerationConfig), *任意*) : 生成呼び出しのベースパラメータ化として使用される生成設定です。 `**kwargs` で `generation_config` の属性に一致するものが generate に渡された場合、それらは上書きされます。 `generation_config` が指定されない場合、デフォルトが使用されます。その読み込み優先順位は以下の通りです: 1) 存在する場合、`generation_config.json` モデルファイルから; 2) モデル設定から。未指定のパラメータは [GenerationConfig](/docs/transformers/main/ja/main_classes/text_generation#transformers.GenerationConfig) のデフォルト値を継承することに注意してください。生成をパラメータ化するには、そのドキュメントを確認する必要があります。

logits_processor (`LogitsProcessorList`, *任意*) : 引数や生成設定から構築されるデフォルトの logits プロセッサを補完する、カスタムの logits プロセッサです。引数や生成設定で既に作成済みの logits プロセッサが渡された場合、エラーが発生します。この機能は上級ユーザー向けです。

stopping_criteria (`StoppingCriteriaList`、*任意*) : 引数と生成設定から構築されるデフォルトの停止条件を補完する、カスタムの停止条件です。引数や生成設定からすでに作成された停止条件が渡された場合、エラーが発生します。停止条件が`scores`入力を依存している場合は、`generate`に`return_dict_in_generate=True, output_scores=True`を渡すことを確認してください。この機能は上級ユーザー向けです。

prefix_allowed_tokens_fn (`Callable[[int, torch.Tensor], list[int]]`、*任意*) : 指定された場合、この関数はビームサーチを各ステップで許可されたトークンのみに制限します。指定されない場合、制約は適用されません。この関数は2つの引数を受け取ります: バッチID `batch_id` と `input_ids`。バッチID `batch_id` と以前に生成されたトークン `inputs_ids` に条件付けられた次の生成ステップの許可トークンのリストを返す必要があります。この引数は、[Autoregressive Entity Retrieval](https://huggingface.co/papers/2010.00904) に記載されているような、プレフィックスに条件付けられた制約付き生成に有用です。

synced_gpus (`bool`, *optional*) : `FullyShardedDataParallel` または DeepSpeed ZeRO Stage 3 を複数 GPU で使用する場合、ある GPU が他の GPU より先に生成を完了した場合のデッドロックを回避するために、このフラグは `True` に設定されます（上書きされない限り）。それ以外の場合は、デフォルトで `False` になります。

assistant_model (`PreTrainedModel`、*任意*) : 生成を高速化するために使用できるアシスタントモデルです。アシスタントモデルは、呼び出し元のモデルと完全に同一のトークナイザーを備えている必要があります。アシスタントモデルによる候補トークンの予測が、呼び出し元のモデルで generate を実行するよりもはるかに高速な場合に、高速化が実現されます。そのため、アシスタントモデルは呼び出し元のモデルよりもはるかに小さいものである必要があります。

streamer (`BaseStreamer`、*任意*) : 生成されたシーケンスのストリーミングに使用される Streamer オブジェクトです。生成されたトークンは `streamer.put(token_ids)` を介して渡され、その後の処理はすべて streamer が担当します。

negative_prompt_ids (`torch.LongTensor`、shape `(batch_size, sequence_length)`、*optional*) : CFG などの一部のプロセッサに必要なネガティブプロンプトです。バッチサイズは入力バッチサイズと一致する必要があります。これは実験的な機能であり、将来のバージョンで API が破壊的に変更される可能性があります。

negative_prompt_attention_mask (`torch.LongTensor`、形状 `(batch_size, sequence_length)`、*任意*) : `negative_prompt_ids` 用の Attention_mask。

custom_generate (`str` または `Callable`、*省略可能*) : 以下のいずれかです: - `str` (Hugging Face Hub リポジトリ名): 標準の `generate` メソッドの代わりに、そのリポジトリ内の `custom_generate/generate.py` で定義されたカスタムの `generate` 関数を実行します。リポジトリが生成ロジックを完全に置き換え、戻り値の型が異なる場合があります。 - `str` (ローカルリポジトリのパス): 上記と同様ですが、ローカルパスから読み込みます。ローカルの `custom_generate/generate.py` が実行されるため、ローカルディレクトリの場合も `trust_remote_code=True` が必要です。 - `Callable`: `generate` は通常の入力準備手順を実行した後、デコーディングループを実行するために提供された callable を呼び出します。詳細については、[ドキュメント](../../generation_strategies#custom-generation-methods)を参照してください。

kwargs (`dict[str, Any]`、*任意*) : `generation_config` のアドホックなパラメータ化、およびモデルの `forward` 関数に転送される追加のモデル固有の kwargs です。モデルがエンコーダー・デコーダーモデルの場合、エンコーダー固有の kwargs にはプレフィックスを付与せず、デコーダー固有の kwargs には *decoder_* をプレフィックスとして付与してください。

**戻り値:** [ModelOutput](/docs/transformers/main/ja/main_classes/output#transformers.utils.ModelOutput) または `torch.LongTensor`

`return_dict_in_generate=True` の場合、または `config.return_dict_in_generate=True` の場合は [ModelOutput](/docs/transformers/main/ja/main_classes/output#transformers.utils.ModelOutput)、それ以外は `torch.LongTensor`。

モデルがエンコーダー・デコーダーモデルで*ない*場合（`model.config.is_encoder_decoder=False`）、考えられる[ModelOutput](/docs/transformers/main/ja/main_classes/output#transformers.utils.ModelOutput)の型は以下の通りです：

- [GenerateDecoderOnlyOutput](/docs/transformers/main/ja/internal/generation_utils#transformers.generation.GenerateDecoderOnlyOutput)、
- [GenerateBeamDecoderOnlyOutput](/docs/transformers/main/ja/internal/generation_utils#transformers.generation.GenerateBeamDecoderOnlyOutput)

モデルがエンコーダー・デコーダーモデル（`model.config.is_encoder_decoder=True`）の場合、考えられる[ModelOutput](/docs/transformers/main/ja/main_classes/output#transformers.utils.ModelOutput)の型は以下の通りです：

- [GenerateEncoderDecoderOutput](/docs/transformers/main/ja/internal/generation_utils#transformers.generation.GenerateEncoderDecoderOutput)、
- [GenerateBeamEncoderDecoderOutput](/docs/transformers/main/ja/internal/generation_utils#transformers.generation.GenerateBeamEncoderDecoderOutput)

言語モデリングヘッドを持つモデルに対して、トークンIDのシーケンスを生成します。

生成を制御するほとんどのパラメータは`generation_config`で設定されます。この引数が渡されない場合、モデルのデフォルトの生成設定が使用されます。`generation_config`の任意の値は、generate()に該当するパラメータを渡すことで上書きできます。例: `.generate(inputs, num_beams=4, do_sample=True)`。

生成戦略の概要とコード例については、[次のガイド](../generation_strategies)を参照してください。

## VibeVoiceModel[[transformers.VibeVoiceModel]]

#### transformers.VibeVoiceModel[[transformers.VibeVoiceModel]]

```python
transformers.VibeVoiceModel(config: VibeVoiceConfig)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice/modeling_vibevoice.py#L241)

**パラメータ:**

config ([VibeVoiceConfig](/docs/transformers/main/ja/model_doc/vibevoice#transformers.VibeVoiceConfig)) : モデルのパラメータをすべて含むモデル設定クラスです。設定ファイルで初期化しても、モデルに関連する重みは読み込まれず、設定のみが読み込まれます。モデルの重みをロードするには、[from_pretrained()](/docs/transformers/main/ja/main_classes/model#transformers.PreTrainedModel.from_pretrained) メソッドを確認してください。

音声トークナイザーとLLMバックボーンで構成され、言語モデリングヘッドを備えないVibeVoiceモデル。

このモデルは [PreTrainedModel](/docs/transformers/main/ja/main_classes/model#transformers.PreTrainedModel) を継承しています。ライブラリがすべてのモデルに対して実装している汎用的なメソッド（ダウンロードや保存、入力埋め込みのリサイズ、ヘッドのプルーニングなど）については、スーパークラスのドキュメントを参照してください。

このモデルは、PyTorchの[torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module)のサブクラスでもあります。通常のPyTorch Moduleとして使用し、一般的な使用方法や動作に関する詳細については、PyTorchのドキュメントを参照してください。

#### forward[[transformers.VibeVoiceModel.forward]]

```python
forward(input_ids: LongTensor = None, inputs_embeds: typing.Optional[torch.Tensor] = None, input_values: typing.Optional[torch.Tensor] = None, padding_mask: typing.Optional[torch.BoolTensor] = None, sample: bool = True, **kwargs: *<class 'transformers.utils.generic.TransformersKwargs'>)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice/modeling_vibevoice.py#L322)

**パラメータ:**

input_ids (`torch.LongTensor`、shape `(batch_size, sequence_length)`、*任意*) : 語彙における入力シーケンスのトークンインデックスです。デフォルトでは、パディングは無視されます。インデックスは [AutoTokenizer](/docs/transformers/main/ja/model_doc/auto#transformers.AutoTokenizer) を使用して取得できます。詳細については、[PreTrainedTokenizer.encode()](/docs/transformers/main/ja/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) および [PreTrainedTokenizer.__call__()](/docs/transformers/main/ja/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) を参照してください。 [入力IDとは何ですか？](../glossary#input-ids)

inputs_embeds (`torch.Tensor`、shape `(batch_size, sequence_length, hidden_size)`、*任意*) : `input_ids` を渡す代わりに、埋め込み表現を直接渡すこともできます。これは、モデル内部の埋め込み参照行列よりも、`input_ids` のインデックスを対応するベクトルに変換する方法をより細かく制御したい場合に有用です。

input_values (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*) : Float values of input raw speech waveform. Values can be obtained by loading a `.flac` or `.wav` audio file into an array of type `list[float]`, a `numpy.ndarray` or a `torch.Tensor`, *e.g.* via the torchcodec library (`pip install torchcodec`) or the soundfile library (`pip install soundfile`). To prepare the array into `input_values`, the [AutoProcessor](/docs/transformers/main/ja/model_doc/auto#transformers.AutoProcessor) should be used for padding and conversion into a tensor of type `torch.Tensor`. See [VibeVoiceProcessor.__call__()](/docs/transformers/main/ja/model_doc/vibevoice#transformers.VibeVoiceProcessor.__call__) for details.

padding_mask (`torch.Tensor`、形状 `(batch_size, padded_audio_length)`) : 音声の埋め込み部分を除去するためのパディングマスク。

sample (`bool`、*任意*、デフォルトは`True`) : 元のモデルと同様に、音響潜在変数にガウスノイズを追加するかどうか（σ-VAE: ノイズのスケールはバッチ項目ごとに N(0, `vae_std`) からサンプリングされる）。False の場合、エンコーダーの出力がそのまま使用されるため、出力は決定論的になります。

**戻り値:** [BaseModelOutputWithPast](/docs/transformers/main/ja/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast) または `tuple(torch.Tensor)`

`torch.Tensor` のタプル（`return_dict=False` が渡された場合、または `config.return_dict=False` の場合）または [BaseModelOutputWithPast](/docs/transformers/main/ja/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPast)。設定（[VibeVoiceConfig](/docs/transformers/main/ja/model_doc/vibevoice#transformers.VibeVoiceConfig)）と入力に応じて、さまざまな要素で構成されます。

[VibeVoiceModel](/docs/transformers/main/ja/model_doc/vibevoice#transformers.VibeVoiceModel)のforwardメソッドは、`__call__`特殊メソッドをオーバーライドします。

この関数内でフォワードパスの手順を定義する必要がありますが、その後、この関数ではなく`Module`インスタンスを呼び出すべきです。前者は前処理と後処理の実行を適切に処理するのに対し、後者はそれらを無視してしまいます。

- **last_hidden_state** (`torch.Tensor`、形状 `(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](/docs/transformers/main/ja/internal/generation_utils#transformers.Cache) のインスタンスです。詳細については、[kv cache ガイド](https://huggingface.co/docs/transformers/en/kv_cache)を参照してください。

  自己アテンションブロック（および `config.is_encoder_decoder=True` の場合、クロスカレンションブロック）の事前計算済みヒドゥンステート（キーとバリュー）を保持します。これらは逐次デコーディングを高速化するために使用できます（`past_key_values` 入力参照）。
- **hidden_states** (`tuple(torch.Tensor)`、*optional*、`output_hidden_states=True` が渡された場合または `config.output_hidden_states=True` の場合に返されます) -- `torch.Tensor` のタプル（モデルに埋め込み層がある場合はその出力用 1 つ、各層の出力用 1 つずつ）で、形状は `(batch_size, sequence_length, hidden_size)` です。

  各層の出力におけるモデルのHidden-states、および任意の初期埋め込み出力。
- **attentions** (`tuple(torch.Tensor)`、*optional*、`output_attentions=True` が渡された場合または `config.output_attentions=True` の場合に返されます) -- `torch.Tensor` のタプル（各レイヤーごとに1つ）、形状は `(batch_size, num_heads, sequence_length, sequence_length)`。

  アテンションのsoftmax後のアテンション重み。自己アテンションヘッド内で加重平均を計算するために使用されます。

#### get_audio_features[[transformers.VibeVoiceModel.get_audio_features]]

```python
get_audio_features(input_values: Tensor, padding_mask: Tensor, sample: bool = True, **kwargs: *<class 'transformers.utils.generic.TransformersKwargs'>)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice/modeling_vibevoice.py#L258)

**パラメータ:**

input_values (`torch.Tensor`) : (正規化された) 音声波形の浮動小数点数値。

padding_mask (`torch.Tensor`、形状 `(batch_size, padded_audio_length)`) : 音声の埋め込み部分を除去するためのパディングマスク。

sample (`bool`、*任意*、デフォルトは`True`) : 元のモデルと同様に、音響潜在変数にガウスノイズを追加するかどうか（σ-VAE: ノイズのスケールはバッチ項目ごとに N(0, `vae_std`) からサンプリングされる）。False の場合、エンコーダーの出力がそのまま使用されるため、出力は決定論的になります。

**戻り値:** [BaseModelOutputWithPooling](/docs/transformers/main/ja/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling) または `tuple(torch.Tensor)`

`torch.Tensor` のタプル（`return_dict=False` が渡された場合、または `config.return_dict=False` の場合）または [BaseModelOutputWithPooling](/docs/transformers/main/ja/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling)。設定（[VibeVoiceConfig](/docs/transformers/main/ja/model_doc/vibevoice#transformers.VibeVoiceConfig)）と入力に応じて、さまざまな要素で構成されます。

このメソッドは、入力された音声波形から、音声埋め込み（入力シーケンス内のプレースホルダー音声トークンを置き換えるもの）と、音響特徴量（拡散のターゲットとして使用されるもの）を取得するために使用されます。

- **last_hidden_state** (`torch.Tensor`、形状 `(batch_size, sequence_length, hidden_size)`) -- モデルの最終層の出力における隠れ状態のシーケンス。
- **pooler_output** (`torch.Tensor`、形状 `(batch_size, hidden_size)`) -- 補助的な事前学習タスクに使用される層をさらに通して処理された後、シーケンスの最初のトークン（分類トークン）の最終層の隠れ状態です。例えば、BERT系のモデルでは、線形層とtanh活性化関数を経て処理された後の分類トークンを返します。この線形層の重みは、事前学習中の次の文予測（分類）目的から学習されます。
- **hidden_states** (`tuple(torch.Tensor)`、*optional*、`output_hidden_states=True` が渡された場合または `config.output_hidden_states=True` の場合に返されます) -- `torch.Tensor` のタプル（モデルに埋め込み層がある場合はその出力用 1 つ、各層の出力用 1 つずつ）で、形状は `(batch_size, sequence_length, hidden_size)` です。

  各層の出力におけるモデルのHidden-states、および任意の初期埋め込み出力。
- **attentions** (`tuple(torch.Tensor)`、*optional*、`output_attentions=True` が渡された場合または `config.output_attentions=True` の場合に返されます) -- `torch.Tensor` のタプル（各レイヤーごとに1つ）、形状は `(batch_size, num_heads, sequence_length, sequence_length)`。

  アテンションのsoftmax後のアテンション重み。自己アテンションヘッド内で加重平均を計算するために使用されます。

#### get_placeholder_mask[[transformers.VibeVoiceModel.get_placeholder_mask]]

```python
get_placeholder_mask(input_ids: LongTensor, inputs_embeds: Tensor, audio_features: Tensor)
```

[ソース](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice/modeling_vibevoice.py#L298)

`input_ids`または`inputs_embeds`からマルチモーダルのプレースホルダーマスクを取得し、プレースホルダートークンの数がマルチモーダル機能の長さと等しいことを確認します。長さが異なる場合、エラーが発生します。

