I am running a python code that runs the 00-gains/gain_getting_started.cfg as a python code
connected remotely to PHL. I get the following error.
Running: ['ssh', 'mha@10.0.0.1', 'sh', './StopMHA;cd', '/home/mha/Poz/Poz_examples/00-gain;mha', '--interactive', '--interface=10.0.0.1', '--port=33337']
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
mha: no process found
Traceback (most recent call last):
File "/home/pi/Poz/Poz_examples/00-gain/gain_getting_started.py", line 188, in <module>
mha.set_val('cmd','prepare')
File "/home/pi/openMHA-4.16.1/openMHA/mha/tools/python/openMHA/MHAConnection.py", line 235, in set_val
return self.set_val_raw(path, value).decode()
File "/home/pi/openMHA-4.16.1/openMHA/mha/tools/python/openMHA/MHAConnection.py", line 200, in set_val_raw
return self._send_command(cmd)
File "/home/pi/openMHA-4.16.1/openMHA/mha/tools/python/openMHA/MHAConnection.py", line 121, in _send_command
raise ValueError(
ValueError: Error sending message b'cmd=prepare\n' with error code 1:
Response: b'\n(mhafw_lib) IO error: (MHAIOFile) Unable to open "1speaker_diffNoise_2ch_OUT.wav" for writing.\n(MHA:failure)'
I see the following on PHL when I log in directly after the failure:
-rw-r--r-- 1 mha mha 1219560 Sep 20 13:19 1speaker_diffNoise_2ch.wav
-rw-r--r-- 1 mha mha 0 Oct 19 18:20 1speaker_diffNoise_2ch_OUT.wav
So the file name get created, but mha is not allowed to write into it.
If I run the .cfg file directly logged into PHL it runs ok.
My code looks like..
mha=setup_PHL()
setup_alsa(mha)
mha.set_val('iolib ',' MHAIOFile')
mha.set_val('mha.addin.algos','[ gain ]')
mha.set_val('mha.addin.gain.min','-20')
mha.set_val('mha.addin.gain.max','20')
mha.set_val('mha.addin.gain.gains','[ -10 10 0 0 0 0 ]')
#mha.set_val('io.in.device','hw:0')
#mha.set_val('io.out.device','hw:0')
mha.set_val('io.in ','1speaker_diffNoise_2ch.wav')
mha.set_val('io.out ','1speaker_diffNoise_2ch_OUT.wav')
What am I missing?
Dan Poznanovic
Getting I/O error on writing
Re: Getting I/O error on writing
If I run the python code (again remote access to PHL) but instead of using the mha.set_val calls to
implement the logic, I read the cfg file in via mha.read_cfg('gain.cfg')
I get a correct execution... no error
-rw-r--r-- 1 mha mha 1219560 Sep 20 13:19 1speaker_diffNoise_2ch.wav
-rw-r--r-- 1 mha mha 1219560 Oct 19 18:58 1speaker_diffNoise_2ch_OUT.wav
=====================================================================
mha=setup_PHL()
mha.read_cfg('gain.cfg')
mha.set_val('cmd','prepare')
mha.set_val('cmd','start')
=====================================================================
Why error in one case and OK in the other???
Dan..
implement the logic, I read the cfg file in via mha.read_cfg('gain.cfg')
I get a correct execution... no error
-rw-r--r-- 1 mha mha 1219560 Sep 20 13:19 1speaker_diffNoise_2ch.wav
-rw-r--r-- 1 mha mha 1219560 Oct 19 18:58 1speaker_diffNoise_2ch_OUT.wav
=====================================================================
mha=setup_PHL()
mha.read_cfg('gain.cfg')
mha.set_val('cmd','prepare')
mha.set_val('cmd','start')
=====================================================================
Why error in one case and OK in the other???
Dan..
Re: Getting I/O error on writing
My code is now running. Not sure what changed. But don't want to waste any more time on this.
Dan..
Dan..
-
- Posts: 119
- Joined: Mon Jun 24, 2019 12:51 pm
Re: Getting I/O error on writing
Good that you have overcome the problem. There can be many reasons why a file cannot be opened for writing, ranging from directory permissions to file system errors.
Here are some tips for debugging such a situation in order to get more information than just "Cannot open file for writing":
* Running MHA on a different device than the controlling computer means that files will be read and written in a different file system than where you are controlling the MHA from. I understand that you had this in mind here.
* When using relative paths for files in the MHA configuration instead of absolute paths, then these file paths are resolved relative to the current working directory of the MHA process. Your change-directory command (cd) that you perform before starting the MHA shows that you are aware of this.
* In order to get more information about the error: Before rebooting the device,
** SSH into the remote device as the same user that you use for starting MHA.
** Perform the same change-directory operations on the remote device.
** Using the shell, try to write to the same file using the same absolute or relative file path as you would with the MHA. E.g. in your case, to see if you can get more information why this file cannot be opened for writing.
Here are some tips for debugging such a situation in order to get more information than just "Cannot open file for writing":
* Running MHA on a different device than the controlling computer means that files will be read and written in a different file system than where you are controlling the MHA from. I understand that you had this in mind here.
* When using relative paths for files in the MHA configuration instead of absolute paths, then these file paths are resolved relative to the current working directory of the MHA process. Your change-directory command (cd) that you perform before starting the MHA shows that you are aware of this.
* In order to get more information about the error: Before rebooting the device,
** SSH into the remote device as the same user that you use for starting MHA.
** Perform the same change-directory operations on the remote device.
** Using the shell, try to write to the same file using the same absolute or relative file path as you would with the MHA. E.g. in your case,
Code: Select all
echo test >"1speaker_diffNoise_2ch_OUT.wav"