###pythonのプログラムでsoxを利用したい
vscodeで音声認識をしたくその過程でsoxを利用したいのですが下記のようなエラーメッセージ出たので解決方法を知りたいです
発生している問題・エラーメッセージ
python
'sox' is not recognized as an internal or external command, operable program or batch file. SoX could not be found! If you do not have SoX, proceed here: - - - http://sox.sourceforge.net/ - - - If you do (or think that you should) have SoX, double-check your path variables. ../data/original/jsut_ver1.1/basic5000/wav\BASIC5000_0001.wav This install of SoX cannot process .wav files. This install of SoX cannot process .wav files. Traceback (most recent call last): File ".\01prepare_wav.py", line 54, in <module> tfm.build_file(input_filepath=wav_path_in, File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\site-packages\sox\transform.py", line 710, in build_file return self.build( File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\site-packages\sox\transform.py", line 593, in build input_format, input_filepath = self._parse_inputs( File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\site-packages\sox\transform.py", line 496, in _parse_inputs input_format['channels'] = file_info.channels(input_filepath) File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\site-packages\sox\file_info.py", line 82, in channels output = soxi(input_filepath, 'c') File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\site-packages\sox\core.py", line 147, in soxi shell_output = subprocess.check_output( File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 411, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 489, in run with Popen(*popenargs, **kwargs) as process: File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Owner\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。
該当のソースコード
python
import sox import os if __name__ == "__main__": original_wav_dir = '../data/original/jsut_ver1.1/basic5000/wav' out_wav_dir = '../data/wav' out_scp_dir = '../data/label/all' os.makedirs(out_wav_dir, exist_ok=True) os.makedirs(out_scp_dir, exist_ok=True) tfm = sox.Transformer() tfm.convert(samplerate=16000) with open(os.path.join(out_scp_dir, 'wav.scp'), mode='w') as scp_file: for i in range(5000): filename = 'BASIC5000_%04d' % (i+1) wav_path_in = os.path.join(original_wav_dir, filename+'.wav') wav_path_out = os.path.join(out_wav_dir, filename+'.wav') print(wav_path_in) if not os.path.exists(wav_path_in): print('Error: Not found %s' % (wav_path_in)) exit() tfm.build_file(input_filepath=wav_path_in, output_filepath=wav_path_out) scp_file.write('%s %s\n' % (filename, os.path.abspath(wav_path_out)))
###試したこと
調べてみると同じエラーメッセージが出ている人がいてその人が解決したように自分も同じ方法をしてみました.
その人がしたこと
- soxをインストールして同じディレクトリ内にsoxを移動
また自分はコマンドライン上に下記のコードを打ち込みパスを通そうとしましたが下記のようなエラーメッセージが発生しました
打ち込んだコード path %path;C:Program Files (x86)\sox-14-4-2
発生したエラー path : The term 'path' is not recognized as the name of a cmdlet, function, script file, or operab le program. Check the spelling of the name, or if a path was included, verify that the path is cor rect and try again. At line:1 char:1 + path %path;C:Program Files (x86)\sox-14-4-2 + ~~~~ + CategoryInfo : ObjectNotFound: (path:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is corre ct and try again. At line:1 char:29 + path %path;C:Program Files (x86)\sox-14-4-2 + ~~~ + CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
となり解決できませんでした
結局原因すらわからず困っています
特にsoxのインストールがうまくいっていないのかパスが通っていないのかすらわかりません.コードはいただいたものなので間違って位はいないと思います.
よろしくお願いします
コメントを受けて追記
soxのダウンロードが上手くいっていない気がします
エラー文に乗っているURLからsoxをダウンロードをしてインストールしたのですが下記のような状況になりました.
- インストールすると追加される二つのショートカットが何かわからず放置していたのですが,クリックしてみると一瞬だけ読み込んですぐに落ちるみたいな状況で機能していません
- 移動したディレクトリとは今実行しているコードのディレクトリである00prepareと同じ場所に移動してあります上記の画像のように
補足情報 (FW/ツールのバージョンなど)
vscode - ver 1.63.2
まだ回答がついていません
会員登録して回答してみよう