尽管提到了路径,但为什么它在路径中显示错误? [关闭]

问题描述 投票:0回答:0
data_dir = ("__path to the audio file folder__")
data_file = os.path.join(data_dir, r"__path to the trancribed text csv")
data = pd.read_csv(data_file)

features = []
labels = []

for i, row in data.iterrows():
    file_path = os.path.join(data_dir, row['path'])
    transcription = row['transcription']
    feature = extract_features(file_path)
    features.append(feature)
    labels.append(transcription)

我应该在哪里声明路径? 显示错误:

Traceback (most recent call last):
  File "c:\Users\Adyatoni\OneDrive\Desktop\PROGRAMS\Beng tts 2", line 28, in <module>
    file_path = os.path.join(data_dir, row['path'])
  File "C:\Users\Adyatoni\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\series.py", line 1012, in __getitem__
    return self._get_value(key)
  File "C:\Users\Adyatoni\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\series.py", line 1121, in _get_value
    loc = self.index.get_loc(label)
  File "C:\Users\Adyatoni\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3654, in get_loc
    raise KeyError(key) from err
KeyError: 'path'

谁能告诉我如何解决这个问题? (P.S.-这是我第一次创建自己的模型)

我试过了:

path = r"C:Users\Adyatoni\OneDrive\Desktop\PROGRAMS\Beng tts.csv"

os.environ.setdefault('path', "C:Users\Adyatoni\OneDrive\Desktop\PROGRAMS\Beng tts.csv")

但是显示同样的错误

python deep-learning neural-network text-to-speech speech-synthesis
© www.soinside.com 2019 - 2024. All rights reserved.