将声音文件导入为sf,但在jupyter笔记本上sf给出名称错误

2024-09-27 18:17:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我通过pip安装Soundfile安装了Soundfile。 这是我的密码:

import soundfile as sf
def speech_file_to_array_fn(batch):
    speech_array, sampling_rate = sf.read(batch["file"])
    batch["speech"] = speech_array
    batch["sampling_rate"] = sampling_rate
    batch["target_text"] = batch["text"]
    return batch

timit = timit.map(speech_file_to_array_fn, remove_columns=timit.column_names["train"], num_proc=4)

但它给出了一个命名错误名称错误:未定义名称“sf”

我看不出这个问题,我在jupyter笔记本上工作


Tags: piptotext名称rate错误batchsf

热门问题