質問編集履歴

2

コメントを受けて追記の部分を追加した

2021/12/29 12:19

投稿

primer57
primer57

スコア2

test CHANGED
File without changes
test CHANGED
@@ -252,6 +252,18 @@
252
252
 
253
253
  よろしくお願いします
254
254
 
255
+ ### コメントを受けて追記
256
+
257
+ soxのダウンロードが上手くいっていない気がします
258
+
259
+ [エラー文に乗っているURL](http://sox.sourceforge.net/)からsoxをダウンロードをしてインストールしたのですが下記のような状況になりました.
260
+
261
+ ![イメージ説明](5c29d78fa38fd3cbb3467edd53ca6bde.png)
262
+
263
+ - インストールすると追加される二つのショートカットが何かわからず放置していたのですが,クリックしてみると一瞬だけ読み込んですぐに落ちるみたいな状況で機能していません
264
+
265
+ - 移動したディレクトリとは今実行しているコードのディレクトリである00prepareと同じ場所に移動してあります上記の画像のように
266
+
255
267
  ### 補足情報 (FW/ツールのバージョンなど)
256
268
 
257
269
  vscode - ver 1.63.2

1

記述途中だった質問を完成させた

2021/12/29 12:19

投稿

primer57
primer57

スコア2

test CHANGED
File without changes
test CHANGED
@@ -6,4 +6,252 @@
6
6
 
7
7
 
8
8
 
9
+ ### 発生している問題・エラーメッセージ
10
+
11
+ ```python
12
+
13
+ 'sox' is not recognized as an internal or external command,
14
+
15
+ operable program or batch file.
16
+
17
+ SoX could not be found!
18
+
19
+
20
+
21
+ If you do not have SoX, proceed here:
22
+
23
+ - - - http://sox.sourceforge.net/ - - -
24
+
25
+
26
+
27
+ If you do (or think that you should) have SoX, double-check your
28
+
29
+ path variables.
30
+
31
+
32
+
33
+ ../data/original/jsut_ver1.1/basic5000/wav\BASIC5000_0001.wav
34
+
35
+ This install of SoX cannot process .wav files.
36
+
37
+ This install of SoX cannot process .wav files.
38
+
39
+ Traceback (most recent call last):
40
+
41
+ File ".\01prepare_wav.py", line 54, in <module>
42
+
43
+ tfm.build_file(input_filepath=wav_path_in,
44
+
45
+ File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\site-packages\sox\transform.py", line 710, in build_file
46
+
47
+ return self.build(
48
+
49
+ File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\site-packages\sox\transform.py", line 593, in build
50
+
51
+ input_format, input_filepath = self._parse_inputs(
52
+
53
+ File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\site-packages\sox\transform.py", line 496, in _parse_inputs
54
+
55
+ input_format['channels'] = file_info.channels(input_filepath)
56
+
57
+ File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\site-packages\sox\file_info.py", line 82, in channels
58
+
59
+ output = soxi(input_filepath, 'c')
60
+
61
+ File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\site-packages\sox\core.py", line 147, in soxi
62
+
63
+ shell_output = subprocess.check_output(
64
+
65
+ File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 411, in check_output
66
+
67
+ return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
68
+
69
+ File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 489, in run
70
+
71
+ with Popen(*popenargs, **kwargs) as process:
72
+
73
+ File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in __init__
74
+
75
+ self._execute_child(args, executable, preexec_fn, close_fds,
76
+
77
+ File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child
78
+
79
+ hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
80
+
81
+ FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。
82
+
9
- ##
83
+ ```
84
+
85
+ ### 該当のソースコード
86
+
87
+ ```python
88
+
89
+
90
+
91
+ import sox
92
+
93
+
94
+
95
+
96
+
97
+ import os
98
+
99
+
100
+
101
+
102
+
103
+ if __name__ == "__main__":
104
+
105
+
106
+
107
+ original_wav_dir = '../data/original/jsut_ver1.1/basic5000/wav'
108
+
109
+
110
+
111
+ out_wav_dir = '../data/wav'
112
+
113
+
114
+
115
+ out_scp_dir = '../data/label/all'
116
+
117
+
118
+
119
+ os.makedirs(out_wav_dir, exist_ok=True)
120
+
121
+ os.makedirs(out_scp_dir, exist_ok=True)
122
+
123
+
124
+
125
+
126
+
127
+ tfm = sox.Transformer()
128
+
129
+
130
+
131
+ tfm.convert(samplerate=16000)
132
+
133
+
134
+
135
+
136
+
137
+ with open(os.path.join(out_scp_dir, 'wav.scp'), mode='w') as scp_file:
138
+
139
+
140
+
141
+ for i in range(5000):
142
+
143
+ filename = 'BASIC5000_%04d' % (i+1)
144
+
145
+
146
+
147
+ wav_path_in = os.path.join(original_wav_dir, filename+'.wav')
148
+
149
+
150
+
151
+ wav_path_out = os.path.join(out_wav_dir, filename+'.wav')
152
+
153
+
154
+
155
+ print(wav_path_in)
156
+
157
+
158
+
159
+ if not os.path.exists(wav_path_in):
160
+
161
+ print('Error: Not found %s' % (wav_path_in))
162
+
163
+ exit()
164
+
165
+
166
+
167
+
168
+
169
+ tfm.build_file(input_filepath=wav_path_in,
170
+
171
+ output_filepath=wav_path_out)
172
+
173
+
174
+
175
+
176
+
177
+ scp_file.write('%s %s\n' %
178
+
179
+ (filename, os.path.abspath(wav_path_out)))
180
+
181
+
182
+
183
+ ```
184
+
185
+
186
+
187
+ ###試したこと
188
+
189
+ 調べてみると同じエラーメッセージが出ている人がいてその人が解決したように自分も同じ方法をしてみました.
190
+
191
+ [その人がしたこと](https://teratail.com/questions/349127)
192
+
193
+ - soxをインストールして同じディレクトリ内にsoxを移動
194
+
195
+
196
+
197
+ また自分はコマンドライン上に下記のコードを打ち込みパスを通そうとしましたが下記のようなエラーメッセージが発生しました
198
+
199
+ ```
200
+
201
+ 打ち込んだコード
202
+
203
+ path %path;C:Program Files (x86)\sox-14-4-2
204
+
205
+ ```
206
+
207
+ ```
208
+
209
+ 発生したエラー
210
+
211
+ path : The term 'path' is not recognized as the name of a cmdlet, function, script file, or operab
212
+
213
+ le program. Check the spelling of the name, or if a path was included, verify that the path is cor
214
+
215
+ rect and try again.
216
+
217
+ At line:1 char:1
218
+
219
+ + path %path;C:Program Files (x86)\sox-14-4-2
220
+
221
+ + ~~~~
222
+
223
+ + CategoryInfo : ObjectNotFound: (path:String) [], CommandNotFoundException
224
+
225
+ + FullyQualifiedErrorId : CommandNotFoundException
226
+
227
+
228
+
229
+ x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable
230
+
231
+ program. Check the spelling of the name, or if a path was included, verify that the path is corre
232
+
233
+ ct and try again.
234
+
235
+ At line:1 char:29
236
+
237
+ + path %path;C:Program Files (x86)\sox-14-4-2
238
+
239
+ + ~~~
240
+
241
+ + CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFoundException
242
+
243
+ + FullyQualifiedErrorId : CommandNotFoundException
244
+
245
+ ```
246
+
247
+ となり解決できませんでした
248
+
249
+ 結局原因すらわからず困っています
250
+
251
+ 特にsoxのインストールがうまくいっていないのかパスが通っていないのかすらわかりません.コードはいただいたものなので間違って位はいないと思います.
252
+
253
+ よろしくお願いします
254
+
255
+ ### 補足情報 (FW/ツールのバージョンなど)
256
+
257
+ vscode - ver 1.63.2