游雁
2024-03-05 88db342d7cb0ba847072789d236490568400933d
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
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
#  MIT License  (https://opensource.org/licenses/MIT)
 
# To install requirements: pip3 install -U "funasr[llm]"
 
from funasr import AutoModel
 
model = AutoModel(model="Qwen-Audio-Chat",
                  model_path=None,
                  )
 
audio_in = "https://github.com/QwenLM/Qwen-Audio/raw/main/assets/audio/1272-128104-0000.flac"
 
# 1st dialogue turn
prompt = 'what does the person say?'
cache = {"history": None}
res = model.generate(input=audio_in, prompt=prompt, cache=cache)
print(res)
 
prompt = 'Find the start time and end time of the word "middle classes"'
# 2nd dialogue turn
res = model.generate(input=None, prompt=prompt, cache=cache)
print(res)