salmonn-inference / examples /example_usage.py
marcosremar2's picture
Upload folder using huggingface_hub
a032fae verified
Raw History Blame Contribute Delete
1.19 kB
"""
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()