<やりたいこと>
OSError: [Errno 22] Invalid argumentの対処をしたいです。raw文字列リテラルを使う方法やファイルパスが間違っていないか確認しましたが解決できませんでした。対処法をご教授いただければと思います。
<エラー内容>
Traceback (most recent call last):
File "convertor.py", line 122, in <module>
cupy_mode(gpu)
File "convertor.py", line 73, in cupy_mode
ds = dataset.WaveDataset(wave_path, -1, True)
File "C:\Users\n\Desktop\Deep_VoiceChanger-master1\Deep_VoiceChanger-master\dataset.py", line 50, in init
self.wave = np.array(load(wave)[1], dtype=float)
File "C:\Users\n\Desktop\Deep_VoiceChanger-master1\Deep_VoiceChanger-master\dataset.py", line 22, in load
bps, data = wav.read(path)
File "C:\Users\n\AppData\Local\Programs\Python\Python37\lib\site-packages\scipy\io\wavfile.py", line 264, in read
fid = open(filename, 'rb')
OSError: [Errno 22] Invalid argument: '"C:\Users\n\Desktop\Deep_VoiceChanger-master1\Deep_VoiceChanger-master\results\test.wav"'
windowsコマンドプロンプトからファイルを指定して実行
C:\Users\n>cd C:\Users\n\Desktop\Deep_VoiceChanger-master1\Deep_VoiceChanger-master
C:\Users\n\Desktop\Deep_VoiceChanger-master1\Deep_VoiceChanger-master>python convertor.py
enter gpu number(if you have no gpu, enter -1)...0
enter netA path...\n\Desktop\Deep_VoiceChanger-master1\Deep_VoiceChanger-master\results\generator_ab.npz"
enter netB path..."C:\Users\n\Desktop\Deep_VoiceChanger-master1\Deep_VoiceChanger-master\results\generator_ba.npz"
enter wave path..."C:\Users\n\Desktop\Deep_VoiceChanger-master1\Deep_VoiceChanger-master\results\test.wav"
enter batch size...16
python3.7.0
python3
1コード 2 3import chainer 4import dataset 5import tqdm 6import queue 7import numpy as np 8from gla.gla_util import GLA 9from nets.models import Generator 10 11def numpy_mode(): 12 with chainer.using_config('train', False): 13 with chainer.no_backprop_mode(): 14 netA_path = input('enter netA path...') 15 netB_path = input('enter netB path...') 16 wave_path = input('enter wave path...') 17 18 ds = dataset.WaveDataset(wave_path, -1, True) 19 20 netA = Generator() 21 netB = Generator() 22 chainer.serializers.load_npz(netA_path, netA) 23 chainer.serializers.load_npz(netB_path, netB) 24 25 que_a = queue.deque() 26 que_ab = queue.deque() 27 que_aba = queue.deque() 28 29 gla = GLA() 30 31 print('converting...') 32 for i in tqdm.tqdm(range(ds.max//dataset.dif)): 33 x_a = ds.get_example(i) 34 x_a = chainer.dataset.convert.concat_examples([x_a], -1) 35 x_a = chainer.Variable(x_a) 36 37 x_ab = netA(x_a) 38 x_aba = netB(x_ab) 39 40 que_a .append(x_a .data[0]) 41 que_ab .append(x_ab .data[0]) 42 que_aba.append(x_aba.data[0]) 43 print('done') 44 45 print('phase estimating...') 46 for i, que, name in zip(range(3), [que_a, que_ab, que_aba], ['a.wav', 'ab.wav', 'aba.wav']): 47 print() 48 print(i+1, '/ 3') 49 wave = np.concatenate([gla.inverse(c_f) for i_f in tqdm.tqdm(que) for c_f in dataset.reverse(i_f)]) 50 print('done...') 51 dataset.save(wave_path + name, 16000, wave) 52 print('wave-file saved at', wave_path + name) 53 54 print('all done') 55 56def cupy_mode(gpu): 57 from gla.gla_gpu import GLA_GPU 58 cp = chainer.cuda.cupy 59 60 with chainer.using_config('train', False): 61 with chainer.no_backprop_mode(): 62 netA_path = input('enter netA path...') 63 netB_path = input('enter netB path...') 64 wave_path = input('enter wave path...') 65 batchsize = int(input('enter batch size...')) 66 chainer.cuda.get_device_from_id(gpu).use() 67 68 ds = dataset.WaveDataset(wave_path, -1, True) 69 70 netA = Generator() 71 netB = Generator() 72 chainer.serializers.load_npz(netA_path, netA) 73 chainer.serializers.load_npz(netB_path, netB) 74 netA.to_gpu() 75 netB.to_gpu() 76 77 que_a = queue.deque() 78 que_ab = queue.deque() 79 que_aba = queue.deque() 80 81 gla = GLA_GPU(batchsize*4) 82 83 print('converting...') 84 l = ds.max//dataset.dif 85 for i in tqdm.tqdm(range(0, l, batchsize)): 86 x_a = [ds.get_example(_i) for _i in range(i, min([i+batchsize, l]))] 87 x_a = chainer.dataset.convert.concat_examples(x_a, gpu) 88 x_a = chainer.Variable(x_a) 89 90 x_ab = netA(x_a) 91 x_aba = netB(x_ab) 92 93 que_a .extend([dataset.reverse(_x) for _x in cp.asnumpy(x_a .data)]) 94 que_ab .extend([dataset.reverse(_x) for _x in cp.asnumpy(x_ab .data)]) 95 que_aba.extend([dataset.reverse(_x) for _x in cp.asnumpy(x_aba.data)]) 96 img_a = np.concatenate(que_a, axis=0) 97 img_ab = np.concatenate(que_ab, axis=0) 98 img_aba = np.concatenate(que_aba, axis=0) 99 print('done') 100 101 print('phase estimating...') 102 for i, img, name in zip(range(3), [img_a, img_ab, img_aba], ['a.wav', 'ab.wav', 'aba.wav']): 103 print() 104 print(i+1, '/ 3') 105 wave = gla.auto_inverse(img) 106 print('done...') 107 dataset.save(wave_path + name, 16000, wave) 108 print('wave-file saved at', wave_path + name) 109 110 print('all done') 111 112if __name__ == "__main__": 113 gpu = int(input('enter gpu number(if you have no gpu, enter -1)...')) 114 if gpu < 0: 115 numpy_mode() 116 else: 117 cupy_mode(gpu) 118
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/05/13 11:06
2020/05/13 11:08
2020/05/13 11:16