Views
No views yet

1import torch
2from transformers import Qwen2_5OmniForConditionalGeneration, Qwen2_5OmniProcessor
3from qwen_omni_utils import process_mm_info
4
5model = Qwen2_5OmniForConditionalGeneration.from_pretrained(
6 "maikezu/ST-QE-SpeechLLM-SpTxt-FT", torch_dtype="auto", device_map="auto"
7)
8processor = Qwen2_5OmniProcessor.from_pretrained("Qwen/Qwen2.5-Omni-7B")
9
10system_prompt = (
11 "You are an evaluator. Given the source and/or audio and a translation, "
12 "respond with only a single float score between 0 and 1 indicating translation "
13 "quality. Output nothing else."
14)
15
16conversation = [
17 {"role": "system", "content": [{"type": "text", "text": system_prompt}]},
18 {"role": "user", "content": [
19 {"type": "audio", "audio": "audio.wav"},
20 {"type": "text", "text": "Source: I love cake.\nTranslation: Ich liebe Kekse."}
21 ]},
22]
23
24text = processor.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False)
25audios, images, videos = process_mm_info([conversation], use_audio_in_video=False)
26inputs = processor(
27 text=text, audio=audios, images=images, videos=videos,
28 return_tensors="pt", use_audio_in_video=False
29).to(model.device).to(model.dtype)
30input_len = inputs["input_ids"].shape[1]
31
32with torch.no_grad():
33 output_ids = model.generate(**inputs, use_audio_in_video=False, max_new_tokens=16, return_audio=False)
34
35score = processor.decode(output_ids[0][input_len:], skip_special_tokens=True).strip()
36print(float(score))1@misc{züfle2026needspeechevaluatespeech,
2 title={Why We Need Speech to Evaluate Speech Translation},
3 author={Maike Züfle and Danni Liu and Vilém Zouhar and Jan Niehues},
4 year={2026},
5 eprint={2605.28227},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2605.28227},
9}