Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

本地路径问题 #90

Open
jiahui-w opened this issue Oct 29, 2024 · 1 comment
Open

本地路径问题 #90

jiahui-w opened this issue Oct 29, 2024 · 1 comment

Comments

@jiahui-w
Copy link

改成读取本地路径的代码后:

conversation = [
{'role': 'system', 'content': 'You are a helpful assistant.'},
{"role": "user", "content": [
{"type": "audio", "audio_url": audio_path},
{"type": "text", "text": "判断音频的音色是男性还是女性"},
]},
]
text = processor.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False)
audios = []
for message in conversation:
if isinstance(message["content"], list):
for ele in message["content"]:
if ele["type"] == "audio":
audios.append(librosa.load(ele['audio_url'], sr=processor.feature_extractor.sampling_rate)[0])

inputs = processor(text=text, audios=audios, return_tensors="pt", padding=True)
inputs.input_ids = inputs.input_ids.to("cuda")

generate_ids = model.generate(**inputs, max_length=256)
generate_ids = generate_ids[:, inputs.input_ids.size(1):]

response = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]

出现警告:
It is strongly recommended to pass the sampling_rate argument to this function. Failing to do so can result in silent errors that might be hard to debug.

@MeowsQAQ
Copy link

我在inputs = processor(text=text, audios=audios, return_tensors="pt", padding=True)这句加了参数sampling_rate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants