File size: 633 Bytes
5a416b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ba773e9
 
5a416b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from transformers import pipeline

# Load lightweight reasoning model
reasoner = pipeline("text2text-generation", model="google/flan-t5-large")

def generate_reasoning(summary, question):
    prompt = f"""
Audio Summary:
Speech: {summary['transcription']}
Main Sound Event: {summary['sound_event']}
Emotion: {summary['emotion']}
Speakers: {summary['speakers']}

Question: {question}
Provide a detailed reasoning-based answer using the audio cues.
"""
    # Use only max_new_tokens to avoid Hugging Face warning about max_length+max_new_tokens.
    result = reasoner(prompt, max_new_tokens=256)[0]["generated_text"]
    return result