This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-License-Identifier: Apache-2.0 | |
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | |
| """ | |
| Reproduce expected outputs for each VoxtralRealtime HF integration test. | |
| Uses vLLM offline inference (as in run_eval.py) to generate reference | |
| transcriptions for every @slow integration test in | |
| test_modeling_voxtral_realtime.py, then saves them to a JSON file. | |
| """ | |
| import json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import os | |
| os.environ["CUDA_VISIBLE_DEVICES"] = "2" | |
| import jiwer | |
| import torch | |
| from datasets import Audio, load_dataset | |
| from transformers import ( | |
| VoxtralRealtimeForConditionalGeneration, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import LasrTokenizer | |
| from transformers.tokenization_utils_sentencepiece import SentencePieceExtractor | |
| from huggingface_hub import hf_hub_download | |
| import sentencepiece | |
| from datasets import load_dataset | |
| from tqdm import tqdm | |
| path = hf_hub_download(repo_id='wuketest/lasr_test', filename='spiece.model') | |
| # vocab_ids, vocab_scores, merges = SentencePieceExtractor(path).extract() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import LasrTokenizer, LasrFeatureExtractor, LasrProcessor | |
| from transformers.tokenization_utils_sentencepiece import SentencePieceExtractor | |
| from huggingface_hub import hf_hub_download | |
| import sentencepiece | |
| from datasets import load_dataset | |
| from tqdm import tqdm | |
| import unicodedata | |
| import re | |
| path = hf_hub_download(repo_id='wuketest/lasr_test', filename='spiece.model') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import AutoProcessor, HiggsAudioForConditionalGeneration | |
| model_id = "eustlb/higgs-v2" | |
| processor = AutoProcessor.from_pretrained(model_id, device_map="cuda") | |
| processor.tokenizer.pad_token = processor.tokenizer.eos_token | |
| model = HiggsAudioForConditionalGeneration.from_pretrained(model_id, device_map="cuda") | |
| # single speaker smart voice | |
| conversation = [ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import AutoProcessor | |
| from transformers.models.mllama.image_processing_mllama import convert_aspect_ratios_to_ids | |
| # Load the chat template from file | |
| with open("/Users/eustachelebihan/dev/add-higgs-v2/tmp/chat_template.jinja", "r") as f: | |
| chat_template = f.read() | |
| # Load expected outputs for comparison | |
| with open("/Users/eustachelebihan/dev/add-higgs-v2/expected/single_speaker_with_smart_voice.txt", "r") as f: | |
| expected_single_speaker_with_smart_voice = f.read() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #run: uv pip install nemo_toolkit[asr] | |
| from nemo.collections.asr.modules import AudioToMelSpectrogramPreprocessor | |
| from transformers import ParakeetFeatureExtractor, ParakeetProcessor | |
| from datasets import load_dataset, Audio | |
| import torch | |
| import numpy as np | |
| torch.use_deterministic_algorithms(True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datasets import load_dataset, Audio | |
| from transformers import VoxtralForConditionalGeneration, VoxtralProcessor | |
| import os | |
| import torch | |
| from whisper.normalizers import EnglishTextNormalizer | |
| import jiwer | |
| os.environ["CUDA_VISIBLE_DEVICES"] = "0" | |
| torch_device = "cuda" if torch.cuda.is_available() else "cpu" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| STATE_DICT_MAPPING = { | |
| # Subsampling layer | |
| r"encoder\.pre_encode\.": r"encoder.subsampling.", | |
| # Subsampling specific mappings | |
| r"encoder\.subsampling\.conv\.": r"encoder.subsampling.layers.", | |
| r"encoder\.subsampling\.out\.": r"encoder.subsampling.linear.", | |
| # # Positional encoding (skip pe buffer) | |
| # r"encoder\.pos_enc\.pe$": None, # Skip buffer | |
| r"encoder\.pos_enc\.": r"encoder.encode_positions.", | |
| # Conformer layers - attention (NeMo already uses self_attn) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # To install NeMo, run: | |
| # uv pip install git+https://github.com/NVIDIA/NeMo.git@b97e42b3dd1c9bcdf37c81c63220744af474c9c0 | |
| from nemo.collections.asr.models import ASRModel | |
| import torch | |
| import os | |
| from datasets import load_dataset | |
| import soundfile as sf | |
| TMP_DIR = "./tmp" |