33 lines
773 B
Python
33 lines
773 B
Python
from funasr import AutoModel
|
|
|
|
|
|
def main():
|
|
model_dir = "FunAudioLLM/fun-asr-nano"
|
|
model = AutoModel(
|
|
model=model_dir,
|
|
trust_remote_code=True,
|
|
remote_code="./model.py",
|
|
device="cuda:0",
|
|
)
|
|
|
|
wav_path = f"{model.model_path}/example/zh.mp3"
|
|
res = model.generate(input=[wav_path], cache={}, batch_size=1)
|
|
text = res[0]["text"]
|
|
print(text)
|
|
|
|
model = AutoModel(
|
|
model=model_dir,
|
|
trust_remote_code=True,
|
|
vad_model="fsmn-vad",
|
|
vad_kwargs={"max_single_segment_time": 30000},
|
|
remote_code="./model.py",
|
|
device="cuda:0",
|
|
)
|
|
res = model.generate(input=[wav_path], cache={}, batch_size=1)
|
|
text = res[0]["text"]
|
|
print(text)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|