[to #42322933] re-place import torchaudio to avoid unnecessary requirements in framework

Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11499744
This commit is contained in:
pangda
2023-01-31 11:33:15 +00:00
committed by yingda.chen
parent 5f0e99996a
commit 3eda77aa4f

View File

@@ -4,7 +4,6 @@ import copy
import os
import datasets
import torchaudio
from datasets import IterableDataset
from PIL import Image
@@ -94,6 +93,7 @@ class NativeIterableDataset(IterableDataset):
if k.endswith('Image:FILE'):
ret[k + ':Object'] = Image.open(fp=ex_cache_path)
if k.endswith('Audio:FILE'):
import torchaudio
waveform_and_rate = torchaudio.load(ex_cache_path)
ret[k + ':Object'] = waveform_and_rate
entity = ret