File size: 1,191 Bytes
a032fae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
SALMONN Example Usage

This script demonstrates how to use the SALMONN inference API.
"""

import sys
sys.path.insert(0, '..')

from inference import SALMONNInference

def main():
    # Initialize model
    print("Loading SALMONN model...")
    model = SALMONNInference(config_path="../config.yaml")
    model.load()
    
    # Example audio file
    audio_file = "sample_audio.wav"
    
    print("\n" + "="*50)
    print("SALMONN Example Usage")
    print("="*50)
    
    # 1. Transcribe audio
    print("\n1. Transcription:")
    text = model.transcribe(audio_file)
    print(f"   {text}")
    
    # 2. Ask questions
    print("\n2. Question Answering:")
    questions = [
        "What language is being spoken?",
        "What is the tone of the speaker?",
        "Is this audio about weather?",
    ]
    
    for q in questions:
        answer = model.chat(audio_file, q)
        print(f"   Q: {q}")
        print(f"   A: {answer}")
        print()
    
    # 3. Describe audio
    print("3. Audio Description:")
    description = model.describe(audio_file)
    print(f"   {description}")
    
    print("\n" + "="*50)
    print("Done!")

if __name__ == "__main__":
    main()