import librosaimport torchfrom transformers import AutoProcessor, Qwen2AudioForConditionalGeneration model_id = "wujunjiehhs/strixAE"audio_path = "example.wav" processor = AutoProcessor.from_pretrained(model_id)model = Qwen2AudioForConditionalGeneration.from_pretrained( model_id, torch_dtype="auto", device_map="auto",) conversation = [ { "role": "system", "content": ( "You are an audio reasoning assistant. Analyze the audio carefully " "and provide a clear, structured answer." ), }, { "role": "user", "content": [ {"type": "audio", "audio": audio_path}, { "type": "text", "text": ( "Identify the audio issues. Evaluate denoising, dereverberation, " "source separation, and super-resolution. For each operation, " "return APPLY or SKIP with a reason, then propose an ordered pipeline." ), }, ], },] prompt = processor.apply_chat_template( conversation, add_generation_prompt=True, tokenize=False,)audio, _ = librosa.load( audio_path, sr=processor.feature_extractor.sampling_rate, mono=True,)inputs = processor( text=prompt, audio=audio, sampling_rate=processor.feature_extractor.sampling_rate, return_tensors="pt", padding=True,)inputs = {k: v.to(model.device) for k, v in inputs.items()} with torch.inference_mode(): generated_ids = model.generate(**inputs, max_new_tokens=1024) generated_ids = generated_ids[:, inputs["input_ids"].shape[1]:]response = processor.batch_decode( generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False,)[0]print(response)