# VibeVoice ASR

## Tổng quan

VibeVoice ASR là một mô hình nhận dạng giọng nói tự động từ Microsoft, kết hợp các bộ mã hóa âm thanh acoustic và semantic với một mô hình ngôn ngữ nhân quả để chuyển đổi giọng nói thành văn bản một cách ổn định. Mô hình sử dụng các bộ mã hóa acoustic và semantic của VibeVoice, xử lý âm thanh ở tần số 24kHz, kết hợp với bộ giải mã ngôn ngữ dựa trên Qwen2 để tạo ra bản ghi âm. Xem [báo cáo kỹ thuật](https://huggingface.co/papers/2601.18184) để biết thêm chi tiết.

Checkpoint của model có sẵn tại: [microsoft/VibeVoice-ASR-HF](https://huggingface.co/microsoft/VibeVoice-ASR-HF)

Điểm nổi bật:

- **🕒 Xử lý một lượt trong 60 phút**: Khác với các mô hình ASR thông thường chia nhỏ âm thanh thành các đoạn ngắn (thường làm mất ngữ cảnh toàn cục), VibeVoice ASR nhận đầu vào âm thanh liên tục lên đến **60 phút** trong độ dài 64K token. Điều này đảm bảo việc theo dõi người nói nhất quán và tính mạch lạc ngữ nghĩa xuyên suốt cả giờ.

- **👤 Từ khóa nóng tùy chỉnh**: Người dùng có thể cung cấp các từ khóa nóng tùy chỉnh (ví dụ: tên riêng, thuật ngữ kỹ thuật hoặc thông tin nền) để định hướng quá trình nhận dạng, cải thiện đáng kể độ chính xác trên nội dung chuyên ngành.

- **📝 Transcription chi tiết (Ai, Khi nào, Nội dung gì)**: Mô hình thực hiện đồng thời ASR, phân tách người nói và gắn mốc thời gian, tạo ra đầu ra có cấu trúc chỉ rõ *ai* đã nói *điều gì* và *khi nào*.
  
- **🌍 Hỗ trợ đa ngôn ngữ & chuyển đổi ngôn ngữ**: Hỗ trợ hơn 50 ngôn ngữ, không yêu cầu thiết lập ngôn ngữ rõ ràng và xử lý tự nhiên việc chuyển đổi ngôn ngữ trong và giữa các câu.

Mô hình này được đóng góp bởi [Eric Bezzam](https://huggingface.co/bezzam).

## Cách sử dụng

Mô hình hỗ trợ nhiều chức năng nhận dạng giọng nói tự động khác nhau.

### Chuyển văn bản có đánh dấu thời gian theo người nói

Một tính năng nổi bật của VibeVoice ASR là khả năng chuyển văn bản nội dung nhiều người nói, chỉ rõ ai đã nói và khi nào.

```python
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.
"""
```

Mô hình VibeVoice ASR được huấn luyện để tạo ra một chuỗi có cấu trúc giống JSON. Cờ `return_format="parsed"` cố gắng trả về đầu ra đã tạo dưới dạng một danh sách các dict, trong khi `return_format="transcription_only"` cố gắng chỉ trích xuất phần âm thanh đã được chuyển tự. Nếu thất bại, đầu ra đã tạo sẽ được trả về nguyên vẹn.

### Cung cấp ngữ cảnh

Bạn cũng có thể cung cấp ngữ cảnh. Điều này hữu ích nếu một số từ không thể được chuyển tự chính xác, chẳng hạn như danh từ riêng.

Dưới đây là bản ghi âm thanh trong đó người nói (với giọng Đức) nói về VibeVoice, so sánh khi có và không có ngữ cảnh "About VibeVoice".

```python
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.
"""
```

### Suy luận theo lô

Việc suy luận theo lô (batch inference) là khả thi bằng cách truyền vào một danh sách audio và, nếu có, một danh sách prompts. Số lượng audio đầu vào và prompts phải khớp nhau (đối với prompts, bạn có thể đặt một mục là `None` nếu không cần thiết cho một audio cụ thể).

```python
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)
```

### Điều chỉnh chunk của tokenizer (ví dụ: nếu xảy ra hết bộ nhớ)

Một tính năng chính của VibeVoice ASR là khả năng chuyển văn bản từ tối đa 60 phút âm thanh liên tục. Điều này được thực hiện bằng cách chia âm thanh thành các đoạn 60 giây (1440000 mẫu ở 24kHz) và lưu trữ trạng thái tích chập giữa các đoạn.

Tuy nhiên, nếu các khối 60 giây quá lớn cho thiết bị của bạn, bạn có thể điều chỉnh đối số `acoustic_tokenizer_chunk_size` được truyền vào `generate`. *Lưu ý rằng giá trị này phải là bội số của độ dài bước nhảy (3200 đối với acoustic tokenizer gốc).*

```python
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)
```

### Mẫu chat

VibeVoice ASR cũng chấp nhận đầu vào theo mẫu chat (`apply_transcription_request` thực chất là một lớp bọc cho `apply_chat_template` để tiện lợi hơn):
```python
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)
```

### Huấn luyện

VibeVoice ASR có thể được huấn luyện bằng loss do mô hình tạo ra.

```python
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

Mô hình có thể được biên dịch để suy luận/đào tạo nhanh hơn.
```python
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")
```

### Cách sử dụng Pipeline

Mô hình có thể được sử dụng như một pipeline, nhưng bạn sẽ phải tự định nghĩa các phương thức để phân tích kết quả đầu ra thô.

```python
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[[transformers.VibeVoiceAsrConfig]]

#### transformers.VibeVoiceAsrConfig[[transformers.VibeVoiceAsrConfig]]

```python
transformers.VibeVoiceAsrConfig(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, acoustic_tokenizer_encoder_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None, semantic_tokenizer_encoder_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None, text_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None, audio_token_id: int = 151648, audio_bos_token_id: int = 151646, audio_eos_token_id: int = 151647, acoustic_tokenizer_chunk_size: int = 1440000)
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice_asr/configuration_vibevoice_asr.py#L31)

**Tham số:**

acoustic_tokenizer_encoder_config (`Union[VibeVoiceAcousticTokenizerConfig, dict]`, *tùy chọn*) : Đối tượng cấu hình hoặc từ điển của bộ mã hóa âm học. Bộ mã hóa này trích xuất các đặc trưng âm học từ âm thanh.

semantic_tokenizer_encoder_config (`Union[VibeVoiceAcousticTokenizerConfig, dict]`, *tùy chọn*) : Đối tượng cấu hình hoặc từ điển của bộ mã hóa ngữ nghĩa. Bộ mã hóa này trích xuất các đặc trưng ngữ nghĩa từ âm thanh.

text_config (`Union[dict, ~configuration_utils.PreTrainedConfig]`, *tùy chọn*) : Đối tượng config hoặc từ điển của text backbone.

audio_token_id (`int`, *tùy chọn*, mặc định là `151648`) : Chỉ số token âm thanh được dùng làm ký tự thay thế cho âm thanh đầu vào.

audio_bos_token_id (`int`, *tuỳ chọn*, mặc định là 151646) : Chỉ số token bắt đầu chuỗi (begin-of-sequence) cho âm thanh.

audio_eos_token_id (`int`, *tuỳ chọn*, mặc định là 151647) : Chỉ số token kết thúc chuỗi (end-of-sequence) của âm thanh.

acoustic_tokenizer_chunk_size (`int`, *optional*, mặc định là 1440000) : Kích thước chunk (tính bằng số mẫu) được sử dụng khi tokenizer các đầu vào âm thanh. Giá trị mặc định tương ứng với 60 giây ở 24kHz.

Đây là lớp cấu hình để lưu trữ cấu hình của một VibeVoiceAsrModel. Nó được sử dụng để khởi tạo một mô hình Vibevoice Asr theo các đối số được chỉ định, xác định kiến trúc của mô hình. Khởi tạo một cấu hình với các giá trị mặc định sẽ tạo ra một cấu hình tương tự như cấu hình của [microsoft/VibeVoice-ASR-HF](https://huggingface.co/microsoft/VibeVoice-ASR-HF)

Các đối tượng cấu hình kế thừa từ [PreTrainedConfig](/docs/transformers/main/vi/main_classes/configuration#transformers.PreTrainedConfig) và có thể được sử dụng để kiểm soát đầu ra của mô hình. Đọc tài liệu từ [PreTrainedConfig](/docs/transformers/main/vi/main_classes/configuration#transformers.PreTrainedConfig) để biết thêm thông tin.

Ví dụ:

```python
>>> 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.config
```

## VibeVoiceAsrProcessor[[transformers.VibeVoiceAsrProcessor]]

#### transformers.VibeVoiceAsrProcessor[[transformers.VibeVoiceAsrProcessor]]

```python
transformers.VibeVoiceAsrProcessor(feature_extractor, tokenizer, chat_template = None, audio_token = '<|box_start|>', audio_bos_token = '<|object_ref_start|>', audio_eos_token = '<|object_ref_end|>', audio_duration_token = '<|AUDIO_DURATION|>')
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice_asr/processing_vibevoice_asr.py#L31)

**Tham số:**

feature_extractor (`VibeVoiceAcousticTokenizerFeatureExtractor`) : Bộ trích xuất đặc trưng cho xử lý âm thanh.

tokenizer (`Qwen2TokenizerFast`) : Bộ phân từ để xử lý văn bản.

chat_template (`str`, *tùy chọn*) : Một mẫu Jinja sẽ được sử dụng để chuyển đổi các danh sách tin nhắn trong một cuộc trò chuyện thành chuỗi có thể token hóa.

audio_token (`str`, *tùy chọn*, mặc định là `"<|box_start|>"`) : Token thay thế cho âm thanh cần sử dụng trong mẫu chat.

audio_bos_token (`str`, *tùy chọn*, mặc định là `"<|object_ref_start|>"`) : Token placeholder cho token bắt đầu chuỗi âm thanh cần sử dụng trong chat template.

audio_eos_token (`str`, *tùy chọn*, mặc định là `"<|object_ref_end|>"`) : Token placeholder cho dấu kết thúc chuỗi âm thanh cần sử dụng trong chat template.

audio_duration_token (`str`, *tùy chọn*, mặc định là `"<|AUDIO_DURATION|>"`) : Token thay thế cho thời lượng âm thanh cần sử dụng trong mẫu chat.

Tạo một bộ xử lý ASR VibeVoice, bao bọc [VibeVoiceAcousticTokenizerFeatureExtractor](/docs/transformers/main/vi/model_doc/vibevoice_acoustic_tokenizer#transformers.VibeVoiceAcousticTokenizerFeatureExtractor) và [Qwen2TokenizerFast](/docs/transformers/main/vi/model_doc/qwen2#transformers.Qwen2Tokenizer) thành một bộ xử lý duy nhất kế thừa cả chức năng trích xuất đặc trưng âm thanh lẫn chức năng tokenizer.

Xem [__call__()](/docs/transformers/main/vi/model_doc/vibevoice_asr#transformers.VibeVoiceAsrProcessor.__call__) để biết thêm thông tin.

#### __call__[[transformers.VibeVoiceAsrProcessor.__call__]]

```python
__call__(text: str | 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.processing_utils.ProcessingKwargs'>)
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice_asr/processing_vibevoice_asr.py#L87)

**Tham số:**

text (`Union[str, list[str]]`) : Chuỗi hoặc lô các chuỗi cần được mã hóa. Mỗi chuỗi có thể là một chuỗi ký tự hoặc một danh sách các chuỗi ký tự (chuỗi đã được tách token trước). Nếu bạn truyền vào đầu vào đã được tách token trước, hãy đặt `is_split_into_words=True` để tránh nhầm lẫn với các đầu vào dạng lô.

audio (`Union[numpy.ndarray, torch.Tensor, collections.abc.Sequence[numpy.ndarray], collections.abc.Sequence[torch.Tensor]]`, *optional*) : Âm thanh hoặc lô âm thanh cần được chuẩn bị. Mỗi âm thanh có thể là mảng NumPy hoặc tensor PyTorch. Trong trường hợp là mảng NumPy/tensor PyTorch, mỗi âm thanh nên có hình dạng (C, T), trong đó C là số kênh và T là độ dài mẫu của âm thanh.

output_labels (`bool`, *tùy chọn*, mặc định=False) : Có trả về nhãn cho việc huấn luyện hay không.

return_mm_token_type_ids (`bool`, *kwargs*) : Có nên trả về các id loại token đa phương thức chỉ định vị trí của các token placeholder đa phương thức hay không.

return_text_replacement_offsets (`bool`, *kwargs*) : Có nên trả về các vị trí ký tự cho mỗi placeholder đa phương thức và phần thay thế của nó hay không.

return_tensors (`str` hoặc [TensorType](/docs/transformers/main/vi/internal/file_utils#transformers.TensorType), *optional*) : Nếu được đặt, sẽ trả về các tensor của một framework cụ thể. Các giá trị chấp nhận được là:  - `'pt'`: Trả về các đối tượng `torch.Tensor` của PyTorch. - `'np'`: Trả về các đối tượng `np.ndarray` của NumPy.

- ****kwargs** ([ProcessingKwargs](/docs/transformers/main/vi/main_classes/processors#transformers.ProcessingKwargs), *optional*) : Các tùy chọn xử lý bổ sung cho từng phương thức (text, images, videos, audio). Các tham số cụ thể của model được liệt kê ở trên; xem lớp TypedDict để biết danh sách đầy đủ các đối số được hỗ trợ.

**Trả về:** [BatchFeature](/docs/transformers/main/vi/main_classes/feature_extractor#transformers.BatchFeature)

Một từ điển chứa văn bản đã được token hóa (`input_ids`, `attention_mask`) và các đặc trưng âm thanh (`input_values`, `padding_mask`).

#### apply_transcription_request[[transformers.VibeVoiceAsrProcessor.apply_transcription_request]]

```python
apply_transcription_request(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 = None, tokenize: bool = True, **kwargs: *<class 'transformers.processing_utils.ProcessingKwargs'>)
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice_asr/processing_vibevoice_asr.py#L170)

**Tham số:**

audio (`str`, `list[str]`, `np.ndarray`, `torch.Tensor`, `list[np.ndarray]`, `list[torch.Tensor]`) : Âm thanh cần chuyển thành văn bản. Chuỗi được hiểu là đường dẫn cục bộ hoặc URL và sẽ được tải tự động bởi trình nạp mẫu chat; mảng NumPy và tensor PyTorch được chuyển tiếp trực tiếp.

prompt (`str` hoặc `list[str]`, *tùy chọn*) : Prompt tùy chỉnh để bao gồm trong lượt người dùng như ngữ cảnh bổ sung. Một danh sách phải có cùng độ dài với batch. Khi `None`, không cung cấp ngữ cảnh bổ sung.

tokenize (`bool`, *tùy chọn*, mặc định là `True`) : Xác định có thực hiện tokenize các prompt và xử lý âm thanh hay không. Nếu `False`, âm thanh sẽ không được tải và các prompt được trả về dưới dạng chuỗi với các placeholder âm thanh chưa được mở rộng. Việc truyền chúng cùng với âm thanh vào processor, `processor(text=prompts, audio=audio)`, sẽ cho ra kết quả giống hệt như khi `tokenize=True`.

- ****kwargs** : Các đối số từ khóa bổ sung được chuyển tiếp đến [apply_chat_template()](/docs/transformers/main/vi/main_classes/processors#transformers.ProcessorMixin.apply_chat_template) (ví dụ `text_kwargs`, `audio_kwargs`, ...).

**Trả về:** [BatchFeature](/docs/transformers/main/vi/main_classes/feature_extractor#transformers.BatchFeature) hoặc `list[str]`

Một prompt cho mỗi tệp âm thanh khi `tokenize=False`, ngược lại bộ xử lý sẽ xuất ra dữ liệu sẵn sàng để truyền vào [VibeVoiceAsrForConditionalGeneration.generate()](/docs/transformers/main/vi/main_classes/text_generation#transformers.GenerationMixin.generate).

Chuẩn bị đầu vào cho nhận dạng giọng nói tự động mà không cần tự viết mẫu trò chuyện.

#### decode[[transformers.VibeVoiceAsrProcessor.decode]]

```python
decode(*args, return_format = 'raw', **kwargs)
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice_asr/processing_vibevoice_asr.py#L226)

**Tham số:**

return_format (`str`, *tùy chọn*, mặc định là `"raw"`) : Các tùy chọn là: - `"raw"`: Trả về một danh sách các chuỗi đã giải mã thô từ tokenizer, không có bất kỳ bước phân tích nào. - `"parsed"`: Trả về một danh sách các danh sách đối từ điển đã phân tích cho mỗi phát ngôn của từng người nói, kèm theo dấu thời gian. - `"transcription_only"`: Trả về một danh sách các chuỗi phiên âm đã trích xuất. `skip_special_tokens` được thực thi tự động (cài đặt cứng) thành `True` cho `"parsed"` và `"transcription_only"`.

Truyền các đối số tới [decode()](/docs/transformers/main/vi/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.decode) và tùy chọn phân tích kết quả đầu ra dạng dict.

VibeVoice ASR xuất ra bản ghi âm trong định dạng giống từ điển, ví dụ:
```
[
    'assistant
":0.0,"End":7.56,"Speaker":0,"Content":"text"}]

    'assistant
":0,"End":5.20,"Speaker":0,"Content":"text"}]

]
```

## VibeVoiceAsrModel[[transformers.VibeVoiceAsrModel]]

#### transformers.VibeVoiceAsrModel[[transformers.VibeVoiceAsrModel]]

```python
transformers.VibeVoiceAsrModel(config: VibeVoiceAsrConfig)
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice_asr/modeling_vibevoice_asr.py#L304)

**Tham số:**

config ([VibeVoiceAsrConfig](/docs/transformers/main/vi/model_doc/vibevoice_asr#transformers.VibeVoiceAsrConfig)) : Lớp cấu hình mô hình chứa tất cả các tham số của mô hình. Khởi tạo bằng tệp cấu hình sẽ không tải trọng số liên quan đến mô hình, chỉ tải cấu hình. Xem phương thức [from_pretrained()](/docs/transformers/main/vi/main_classes/model#transformers.PreTrainedModel.from_pretrained) để tải trọng số mô hình.

Mô hình VibeVoice ASR (tokenizer âm học + tokenizer ngữ nghĩa + bộ chiếu đa phương thức + mô hình ngôn ngữ), không có đầu mô hình hóa ngôn ngữ.

Mô hình này kế thừa từ [PreTrainedModel](/docs/transformers/main/vi/main_classes/model#transformers.PreTrainedModel). Xem tài liệu của lớp cha để biết các phương thức chung mà thư viện triển khai cho tất cả các mô hình của nó (chẳng hạn như tải xuống hoặc lưu trữ, thay đổi kích thước các nhúng đầu vào, cắt tỉa các đầu ra, v.v.)

Mô hình này cũng là một lớp con của [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) trong PyTorch. Hãy sử dụng nó như một Module PyTorch thông thường và tham khảo tài liệu PyTorch cho mọi vấn đề liên quan đến cách sử dụng và hành vi chung.

#### forward[[transformers.VibeVoiceAsrModel.forward]]

```python
forward(input_ids: typing.Optional[torch.LongTensor] = None, attention_mask: typing.Optional[torch.Tensor] = None, cache: transformers.cache_utils.Cache | None = 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'>)
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice_asr/modeling_vibevoice_asr.py#L379)

**Tham số:**

input_ids (`torch.LongTensor` có hình dạng `(batch_size, sequence_length)`, *tùy chọn*) : Chỉ số của các token trong chuỗi đầu vào theo từ vựng. Mặc định, các token đệm (padding) sẽ bị bỏ qua. Có thể lấy chỉ số bằng cách sử dụng [AutoTokenizer](/docs/transformers/main/vi/model_doc/auto#transformers.AutoTokenizer). Xem [PreTrainedTokenizer.encode()](/docs/transformers/main/vi/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) và [PreTrainedTokenizer.__call__()](/docs/transformers/main/vi/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) để biết chi tiết. [ID đầu vào là gì?](../glossary#input-ids)

attention_mask (`torch.Tensor` có hình dạng `(batch_size, sequence_length)`, *tùy chọn*) : Mặt nạ để tránh thực hiện chú ý trên các chỉ số token đệm. Các giá trị mặt nạ được chọn trong `[0, 1]`:  - 1 cho các token **không bị che**, - 0 cho các token **bị che**.  [Mặt nạ chú ý là gì?](../glossary#attention-mask)

cache (`~cache_utils.Cache`, *tùy chọn*) : Các hidden-states đã tính trước (key và values trong các khối self-attention và cross-attention) có thể được sử dụng để tăng tốc giải mã tuần tự. Thông thường, đây là `cache` do mô hình trả về ở một giai đoạn giải mã trước đó, khi `use_cache=True` hoặc `config.use_cache=True`. Chỉ cho phép nhập một instance của [Cache](/docs/transformers/main/vi/internal/generation_utils#transformers.Cache), xem [hướng dẫn về kv cache](https://huggingface.co/docs/transformers/en/kv_cache) của chúng tôi. Nếu không truyền `cache`, [DynamicCache](/docs/transformers/main/vi/internal/generation_utils#transformers.DynamicCache) sẽ được khởi tạo theo mặc định. Mô hình sẽ xuất ra cùng định dạng cache được đưa vào làm đầu vào. Nếu sử dụng `cache`, người dùng được kỳ vọng chỉ nhập các `input_ids` chưa được xử lý (những phần chưa có trạng thái key value trong quá khứ được cung cấp cho mô hình này) với shape `(batch_size, unprocessed_length)` thay vì toàn bộ `input_ids` với shape `(batch_size, sequence_length)`.

inputs_embeds (`torch.Tensor` có hình dạng `(batch_size, sequence_length, hidden_size)`, *tùy chọn*) : Tùy chọn, thay vì truyền `input_ids`, bạn có thể chọn cách truyền trực tiếp một biểu diễn nhúng. Điều này hữu ích nếu bạn muốn kiểm soát nhiều hơn cách chuyển đổi các chỉ số `input_ids` thành các vector liên quan so với ma trận tra cứu nhúng nội bộ của mô hình.

input_values (`torch.Tensor` có shape `(batch_size, sequence_length)`, *tùy chọn*) : Các giá trị float của dạng sóng âm thanh thô đầu vào. Các giá trị này có thể được lấy bằng cách nạp tệp âm thanh `.flac` hoặc `.wav` vào một mảng có kiểu `list[float]`, một `numpy.ndarray` hoặc một `torch.Tensor`, *chẳng hạn* thông qua thư viện torchcodec (`pip install torchcodec`) hoặc thư viện soundfile (`pip install soundfile`). Để chuẩn bị mảng thành `input_values`, cần sử dụng [AutoProcessor](/docs/transformers/main/vi/model_doc/auto#transformers.AutoProcessor) để đệm (padding) và chuyển đổi thành tensor có kiểu `torch.Tensor`. Xem `processor_class.__call__` để biết chi tiết.

padding_mask (`torch.BoolTensor` có hình dạng `(batch_size, sequence_length)`, *tùy chọn*) : Mặt nạ để tránh thực hiện các thao tác trên các chỉ mục tính năng đệm (padding).

sample (`bool`, *tuỳ chọn*, mặc định là `True`) : Có thêm nhiễu Gaussian vào các ẩn âm thanh hay không, như trong mô hình gốc (σ-VAE: thang nhiễu được rút ngẫu nhiên cho từng mục trong batch từ N(0, `vae_std`)). Nếu là False, đầu ra của bộ mã hóa sẽ được sử dụng nguyên vẹn, do đó đầu ra là tất định.

**Trả về:** `VibeVoiceAsrModelOutputWithPast` hoặc `tuple(torch.Tensor)`

Một `VibeVoiceAsrModelOutputWithPast` hoặc một tuple của `torch.Tensor` (nếu `return_dict=False` được truyền hoặc khi `config.return_dict=False`) bao gồm các phần tử khác nhau tùy thuộc vào cấu hình (`None`) và đầu vào.

Phương thức forward của [VibeVoiceAsrModel](/docs/transformers/main/vi/model_doc/vibevoice_asr#transformers.VibeVoiceAsrModel) ghi đè lên phương thức đặc biệt `__call__`.

Mặc dù công thức cho bước truyền tiến cần được định nghĩa bên trong hàm này, bạn nên gọi instance của `Module` sau đó thay vì gọi hàm này, vì instance `Module` sẽ đảm nhận việc thực hiện các bước tiền xử lý và hậu xử lý, trong khi hàm này sẽ bỏ qua chúng một cách im lặng.

- **last_hidden_state** (`torch.Tensor` có hình dạng `(batch_size, sequence_length, hidden_size)`) -- Chuỗi các hidden-state tại đầu ra của lớp cuối cùng của mô hình.

  Nếu `cache` được sử dụng, chỉ có hidden-state cuối cùng của các chuỗi có shape `(batch_size, 1, hidden_size)` được xuất ra.
- **cache** (`Cache`, *tuỳ chọn*, được trả về khi `use_cache=True` được truyền vào hoặc khi `config.use_cache=True`) -- Đây là một instance của [Cache](/docs/transformers/main/vi/internal/generation_utils#transformers.Cache).
- **hidden_states** (`tuple(torch.Tensor)`, *tuỳ chọn*, được trả về khi `output_hidden_states=True` được truyền vào hoặc khi `config.output_hidden_states=True`) -- Bộ tuple của `torch.Tensor` (một cho đầu ra của các embedding, nếu mô hình có lớp embedding, + một cho đầu ra của mỗi lớp) có hình dạng `(batch_size, sequence_length, hidden_size)`.

  Trạng thái ẩn của mô hình tại đầu ra của mỗi lớp cùng với các đầu ra embedding ban đầu tùy chọn.
- **attentions** (`tuple(torch.Tensor)`, *tuỳ chọn*, được trả về khi `output_attentions=True` được truyền vào hoặc khi `config.output_attentions=True`) -- Bộ tuple của `torch.Tensor` (một cho mỗi lớp) có hình dạng `(batch_size, num_heads, sequence_length, sequence_length)`.

  Trọng số chú ý sau softmax của attention, được sử dụng để tính trung bình có trọng số trong các đầu self-attention.
- **audio_hidden_states** (`torch.Tensor`, *tùy chọn*) -- Trạng thái ẩn âm thanh đã được chiếu.

## VibeVoiceAsrForConditionalGeneration[[transformers.VibeVoiceAsrForConditionalGeneration]]

#### transformers.VibeVoiceAsrForConditionalGeneration[[transformers.VibeVoiceAsrForConditionalGeneration]]

```python
transformers.VibeVoiceAsrForConditionalGeneration(config: VibeVoiceAsrConfig)
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice_asr/modeling_vibevoice_asr.py#L436)

**Tham số:**

config ([VibeVoiceAsrConfig](/docs/transformers/main/vi/model_doc/vibevoice_asr#transformers.VibeVoiceAsrConfig)) : Lớp cấu hình mô hình chứa tất cả các tham số của mô hình. Khởi tạo bằng tệp cấu hình sẽ không tải trọng số liên quan đến mô hình, chỉ tải cấu hình. Xem phương thức [from_pretrained()](/docs/transformers/main/vi/main_classes/model#transformers.PreTrainedModel.from_pretrained) để tải trọng số mô hình.

Mô hình VibeVoice ASR với các bộ mã hóa âm học được huấn luyện trước và một mô hình ngôn ngữ.

Mô hình này kế thừa từ [PreTrainedModel](/docs/transformers/main/vi/main_classes/model#transformers.PreTrainedModel). Xem tài liệu của lớp cha để biết các phương thức chung mà thư viện triển khai cho tất cả các mô hình của nó (chẳng hạn như tải xuống hoặc lưu trữ, thay đổi kích thước các nhúng đầu vào, cắt tỉa các đầu ra, v.v.)

Mô hình này cũng là một lớp con của [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) trong PyTorch. Hãy sử dụng nó như một Module PyTorch thông thường và tham khảo tài liệu PyTorch cho mọi vấn đề liên quan đến cách sử dụng và hành vi chung.

#### forward[[transformers.VibeVoiceAsrForConditionalGeneration.forward]]

```python
forward(input_ids: typing.Optional[torch.LongTensor] = None, attention_mask: typing.Optional[torch.Tensor] = None, cache: transformers.cache_utils.Cache | None = None, inputs_embeds: typing.Optional[torch.Tensor] = None, input_values: typing.Optional[torch.Tensor] = None, padding_mask: typing.Optional[torch.BoolTensor] = None, labels: typing.Optional[torch.LongTensor] = None, logits_to_keep: typing.Union[int, torch.Tensor] = 0, sample: bool = True, **kwargs: *<class 'transformers.utils.generic.TransformersKwargs'>)
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice_asr/modeling_vibevoice_asr.py#L446)

**Tham số:**

input_ids (`torch.LongTensor` có hình dạng `(batch_size, sequence_length)`, *tùy chọn*) : Chỉ số của các token trong chuỗi đầu vào theo từ vựng. Mặc định, các token đệm (padding) sẽ bị bỏ qua. Có thể lấy chỉ số bằng cách sử dụng [AutoTokenizer](/docs/transformers/main/vi/model_doc/auto#transformers.AutoTokenizer). Xem [PreTrainedTokenizer.encode()](/docs/transformers/main/vi/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.encode) và [PreTrainedTokenizer.__call__()](/docs/transformers/main/vi/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.__call__) để biết chi tiết. [ID đầu vào là gì?](../glossary#input-ids)

attention_mask (`torch.Tensor` có hình dạng `(batch_size, sequence_length)`, *tùy chọn*) : Mặt nạ để tránh thực hiện chú ý trên các chỉ số token đệm. Các giá trị mặt nạ được chọn trong `[0, 1]`:  - 1 cho các token **không bị che**, - 0 cho các token **bị che**.  [Mặt nạ chú ý là gì?](../glossary#attention-mask)

cache (`~cache_utils.Cache`, *tùy chọn*) : Các hidden-states đã tính trước (key và values trong các khối self-attention và cross-attention) có thể được sử dụng để tăng tốc giải mã tuần tự. Thông thường, đây là `cache` do mô hình trả về ở một giai đoạn giải mã trước đó, khi `use_cache=True` hoặc `config.use_cache=True`. Chỉ cho phép nhập một instance của [Cache](/docs/transformers/main/vi/internal/generation_utils#transformers.Cache), xem [hướng dẫn về kv cache](https://huggingface.co/docs/transformers/en/kv_cache) của chúng tôi. Nếu không truyền `cache`, [DynamicCache](/docs/transformers/main/vi/internal/generation_utils#transformers.DynamicCache) sẽ được khởi tạo theo mặc định. Mô hình sẽ xuất ra cùng định dạng cache được đưa vào làm đầu vào. Nếu sử dụng `cache`, người dùng được kỳ vọng chỉ nhập các `input_ids` chưa được xử lý (những phần chưa có trạng thái key value trong quá khứ được cung cấp cho mô hình này) với shape `(batch_size, unprocessed_length)` thay vì toàn bộ `input_ids` với shape `(batch_size, sequence_length)`.

inputs_embeds (`torch.Tensor` có hình dạng `(batch_size, sequence_length, hidden_size)`, *tùy chọn*) : Tùy chọn, thay vì truyền `input_ids`, bạn có thể chọn cách truyền trực tiếp một biểu diễn nhúng. Điều này hữu ích nếu bạn muốn kiểm soát nhiều hơn cách chuyển đổi các chỉ số `input_ids` thành các vector liên quan so với ma trận tra cứu nhúng nội bộ của mô hình.

input_values (`torch.Tensor` có shape `(batch_size, sequence_length)`, *tùy chọn*) : Các giá trị float của dạng sóng âm thanh thô đầu vào. Các giá trị này có thể được lấy bằng cách nạp tệp âm thanh `.flac` hoặc `.wav` vào một mảng có kiểu `list[float]`, một `numpy.ndarray` hoặc một `torch.Tensor`, *chẳng hạn* thông qua thư viện torchcodec (`pip install torchcodec`) hoặc thư viện soundfile (`pip install soundfile`). Để chuẩn bị mảng thành `input_values`, cần sử dụng [AutoProcessor](/docs/transformers/main/vi/model_doc/auto#transformers.AutoProcessor) để đệm (padding) và chuyển đổi thành tensor có kiểu `torch.Tensor`. Xem `processor_class.__call__` để biết chi tiết.

padding_mask (`torch.BoolTensor` có hình dạng `(batch_size, sequence_length)`, *tùy chọn*) : Mặt nạ để tránh thực hiện các thao tác trên các chỉ mục tính năng đệm (padding).

labels (`torch.LongTensor` có hình dạng `(batch_size, sequence_length)`, *tùy chọn*) : Nhãn để tính toán tổn thất mô hình hóa ngôn ngữ có mặt nạ. Chỉ số phải nằm trong `[0, ..., config.vocab_size]` hoặc -100 (xem docstring của `input_ids`). Các token có chỉ số được đặt thành `-100` sẽ bị bỏ qua (mặt nạ), tổn thất chỉ được tính cho các token có nhãn nằm trong `[0, ..., config.vocab_size]`.

logits_to_keep (`Union[int, torch.Tensor]`, *tùy chọn*, mặc định là `0`) : Nếu là `int`, tính logits cho `logits_to_keep` token cuối. Nếu là `0`, tính logits cho tất cả `input_ids` (trường hợp đặc biệt). Chỉ cần logits của token cuối cho quá trình sinh, và việc chỉ tính cho token đó có thể tiết kiệm bộ nhớ, điều này trở nên khá đáng kể với các chuỗi dài hoặc kích thước từ vựng lớn. Nếu là `torch.Tensor`, phải là 1 chiều tương ứng với các chỉ số cần giữ trong chiều độ dài chuỗi. Điều này hữu ích khi sử dụng định dạng tensor đóng gói (một chiều duy nhất cho batch và độ dài chuỗi).

sample (`bool`, *tuỳ chọn*, mặc định là `True`) : Có thêm nhiễu Gaussian vào các ẩn âm thanh hay không, như trong mô hình gốc (σ-VAE: thang nhiễu được rút ngẫu nhiên cho từng mục trong batch từ N(0, `vae_std`)). Nếu là False, đầu ra của bộ mã hóa sẽ được sử dụng nguyên vẹn, do đó đầu ra là tất định.

**Trả về:** `VibeVoiceAsrCausalLMOutputWithPast` hoặc `tuple(torch.Tensor)`

Một `VibeVoiceAsrCausalLMOutputWithPast` hoặc một tuple của `torch.Tensor` (nếu `return_dict=False` được truyền hoặc khi `config.return_dict=False`) bao gồm các phần tử khác nhau tùy thuộc vào cấu hình (`None`) và đầu vào.

Phương thức forward của [VibeVoiceAsrForConditionalGeneration](/docs/transformers/main/vi/model_doc/vibevoice_asr#transformers.VibeVoiceAsrForConditionalGeneration) ghi đè lên phương thức đặc biệt `__call__`.

Mặc dù công thức cho bước truyền tiến cần được định nghĩa bên trong hàm này, bạn nên gọi instance của `Module` sau đó thay vì gọi hàm này, vì instance `Module` sẽ đảm nhận việc thực hiện các bước tiền xử lý và hậu xử lý, trong khi hàm này sẽ bỏ qua chúng một cách im lặng.

- **loss** (`torch.Tensor` có shape `(1,)`, *tuỳ chọn*, được trả về khi `labels` được cung cấp) -- Loss của language modeling.
- **logits** (`torch.Tensor` có hình dạng `(batch_size, sequence_length, config.vocab_size)`) -- Điểm dự đoán.
- **cache** (`Cache`, *tùy chọn*) -- Instance của Cache.
- **hidden_states** (`tuple[torch.Tensor]`, *tuỳ chọn*, được trả về khi `output_hidden_states=True` được truyền vào hoặc khi `config.output_hidden_states=True`) -- Bộ tuple các `torch.Tensor` (một cho đầu ra của embeddings, nếu mô hình có lớp embedding, + một cho đầu ra của mỗi lớp) có hình dạng `(batch_size, sequence_length, hidden_size)`.

  Trạng thái ẩn của mô hình tại đầu ra của mỗi lớp cùng với các đầu ra embedding ban đầu tùy chọn.
- **attentions** (`tuple[torch.Tensor]`, *tuỳ chọn*, được trả về khi `output_attentions=True` được truyền vào hoặc khi `config.output_attentions=True`) -- Bộ tuple của `torch.Tensor` (một cho mỗi lớp) có hình dạng `(batch_size, num_heads, sequence_length, sequence_length)`.

  Trọng số chú ý sau softmax của attention, được sử dụng để tính trung bình có trọng số trong các đầu self-attention.
- **audio_hidden_states** (`torch.Tensor`, *tùy chọn*) -- Trạng thái ẩn âm thanh đã được chiếu.

Ví dụ:

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

>>> model_id = "microsoft/VibeVoice-ASR-HF"
>>> processor = AutoProcessor.from_pretrained(model_id)
>>> model = VibeVoiceAsrForConditionalGeneration.from_pretrained(model_id, dtype="auto", device_map="auto")
```

#### get_audio_features[[transformers.VibeVoiceAsrForConditionalGeneration.get_audio_features]]

```python
get_audio_features(*args, **kwargs)
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/vibevoice_asr/modeling_vibevoice_asr.py#L443)

