-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
26 lines (20 loc) · 811 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#import packages
import utils
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.generation import GenerationConfig
import torch
torch.manual_seed(1234)
#import model and tok
tokenizer = AutoTokenizer.from_pretrained("audio_models/Qwen-Audio-Chat", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("audio_models/Qwen-Audio-Chat", trust_remote_code=True).eval()
#define the input audio file and text prompt
query = tokenizer.from_list_format([
{'audio': 'data/happy_speech.wav'}, # Either a local path or an url
{'text': 'can you describe the scene ?'},
])
global history
#initiate first turn
response, history = model.chat(tokenizer, query=query, history=None)
print(response)
#continue the dialog (2+ turns). type "end" to end the dialog.
dialog()