running pytest Searching for pytest-cov Best match: pytest-cov 2.8.1 Processing pytest_cov-2.8.1-py3.5.egg Using /home/dpovey/kaldiio/.eggs/pytest_cov-2.8.1-py3.5.egg Searching for coverage>=4.4 Best match: coverage 5.0a8 Processing coverage-5.0a8-py3.5-linux-x86_64.egg Using /home/dpovey/kaldiio/.eggs/coverage-5.0a8-py3.5-linux-x86_64.egg running egg_info writing kaldiio.egg-info/PKG-INFO writing requirements to kaldiio.egg-info/requires.txt writing dependency_links to kaldiio.egg-info/dependency_links.txt writing top-level names to kaldiio.egg-info/top_level.txt reading manifest file 'kaldiio.egg-info/SOURCES.txt' writing manifest file 'kaldiio.egg-info/SOURCES.txt' running build_ext ============================================================================== test session starts ============================================================================== platform linux -- Python 3.5.3, pytest-4.3.0, py-1.8.0, pluggy-0.9.0 rootdir: /home/dpovey/kaldiio, inifile: setup.cfg plugins: cov-2.8.1 collected 109 items tests/test_highlevel.py ....... [ 6%] tests/test_mat_ark.py .....FFFFFFFFFFFFFFFFFFFFFFFF...FFFFFFF..... [ 46%] tests/test_multi_file_descriptor.py .......................... [ 70%] tests/test_open_like_kaldi.py .. [ 72%] tests/test_parse_specifier.py ........ [ 79%] tests/test_wav.py ...................... [100%] =================================================================================== FAILURES ==================================================================================== __________________________________________________________________ test_write_read[float32-<-shape10-shape20] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap0'), shape1 = (1000, 120), shape2 = (10, 120), endian = '<', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.38616645, 0.17594437, 0.7289028 , ..., 0.8923994 , 0.31112653,\n 0.78642297],\n [0.6938...243798],\n [0.50447315, 0.09648972, 0.00446159, ..., 0.9814116 , 0.06616461,\n 0.7321836 ]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap0/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float32-<-shape11-shape21] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap1'), shape1 = (0, 0), shape2 = (0, 120), endian = '<', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap1/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([], shape=(0, 0), dtype=float32), '\u3042\u3044\u3046\u3048\u304a': array([], shape=(0, 120), dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap1/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float32-<-shape12-shape22] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap2'), shape1 = (100,), shape2 = (120,), endian = '<', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap2/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([0.5602168 , 0.13943288, 0.6692633 , 0.01487285, 0.7215614 ,\n 0.96464074, 0.93685764, 0.7397863 ...7153, 0.8099103 , 0.6695035 ,\n 0.5572782 , 0.38490325, 0.14267054, 0.26893413, 0.82190114],\n dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap2/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float32->-shape10-shape20] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap3'), shape1 = (1000, 120), shape2 = (10, 120), endian = '>', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap3/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.15930295, 0.7085175 , 0.4263282 , ..., 0.92351097, 0.9220717 ,\n 0.8206527 ],\n [0.3648...01327 ],\n [0.15815464, 0.20579943, 0.37814522, ..., 0.8547854 , 0.85715914,\n 0.8499018 ]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap3/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float32->-shape11-shape21] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap4'), shape1 = (0, 0), shape2 = (0, 120), endian = '>', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap4/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([], shape=(0, 0), dtype=float32), '\u3042\u3044\u3046\u3048\u304a': array([], shape=(0, 120), dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap4/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float32->-shape12-shape22] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap5'), shape1 = (100,), shape2 = (120,), endian = '>', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap5/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([0.2768953 , 0.11836042, 0.72580993, 0.42591885, 0.6152571 ,\n 0.77958494, 0.8983611 , 0.6644604 ...127 , 0.2708563 , 0.17953776,\n 0.8665823 , 0.9101397 , 0.64519787, 0.0842212 , 0.28955775],\n dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float32___shap5/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float64-<-shape10-shape20] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap0'), shape1 = (1000, 120), shape2 = (10, 120), endian = '<', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.62392527, 0.29947727, 0.660648 , ..., 0.76139016, 0.78220787,\n 0.53654599],\n [0.1616...2,\n 0.91571943],\n [0.69905786, 0.39800609, 0.29679169, ..., 0.43888011, 0.14800008,\n 0.36468591]])} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap0/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float64-<-shape11-shape21] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap1'), shape1 = (0, 0), shape2 = (0, 120), endian = '<', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap1/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([], shape=(0, 0), dtype=float64), '\u3042\u3044\u3046\u3048\u304a': array([], shape=(0, 120), dtype=float64)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap1/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float64-<-shape12-shape22] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap2'), shape1 = (100,), shape2 = (120,), endian = '<', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap2/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([8.73694473e-01, 2.12252094e-01, 1.67445256e-01, 7.25720092e-01,\n 6.03650211e-01, 3.67460718e-01...3, 0.90242879, 0.62143351, 0.72884862, 0.57077085,\n 0.85254113, 0.33333471, 0.97354085, 0.40878558, 0.28974836])} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap2/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float64->-shape10-shape20] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap3'), shape1 = (1000, 120), shape2 = (10, 120), endian = '>', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap3/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.54267613, 0.57305253, 0.86909093, ..., 0.53062467, 0.83092629,\n 0.01897134],\n [0.4274...5,\n 0.83262088],\n [0.3377446 , 0.1984682 , 0.26011641, ..., 0.54809432, 0.1891992 ,\n 0.95337699]])} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap3/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float64->-shape11-shape21] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap4'), shape1 = (0, 0), shape2 = (0, 120), endian = '>', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap4/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([], shape=(0, 0), dtype=float64), '\u3042\u3044\u3046\u3048\u304a': array([], shape=(0, 120), dtype=float64)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap4/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError __________________________________________________________________ test_write_read[float64->-shape12-shape22] ___________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap5'), shape1 = (100,), shape2 = (120,), endian = '>', dtype = @pytest.mark.parametrize('shape1,shape2', [[(1000, 120), (10, 120)], [(0, 0), (0, 120)], [(100,), (120,)], ]) @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read(tmpdir, shape1, shape2, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(*shape1).astype(dtype) b = np.random.rand(*shape2).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:37: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap5/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([0.90082151, 0.96615444, 0.23211743, 0.29774863, 0.73662464,\n 0.26147067, 0.62381084, 0.23583799...2, 0.17238511, 0.46060558, 0.99238918, 0.03266029,\n 0.85953774, 0.55092735, 0.49177298, 0.0071323 , 0.96952207])} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_float64___shap5/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError ______________________________________________________________________ test_write_read_multiark[float32-<] ______________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float0'), endian = '<', dtype = @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read_multiark(tmpdir, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(dtype) b = np.random.rand(10, 120).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:62: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.7510209 , 0.74131966, 0.93412143, ..., 0.3548168 , 0.96587354,\n 0.3904155 ],\n [0.9009...74022 ],\n [0.20014523, 0.27590778, 0.00359516, ..., 0.5086091 , 0.68330616,\n 0.23579687]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float0/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError ______________________________________________________________________ test_write_read_multiark[float32->] ______________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float1'), endian = '>', dtype = @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read_multiark(tmpdir, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(dtype) b = np.random.rand(10, 120).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:62: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float1/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.51698667, 0.7200484 , 0.60191596, ..., 0.6855193 , 0.5982049 ,\n 0.18803632],\n [0.3458...271885],\n [0.9361362 , 0.6435344 , 0.5085137 , ..., 0.60954165, 0.8762882 ,\n 0.14341895]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float1/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError ______________________________________________________________________ test_write_read_multiark[float64-<] ______________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float2'), endian = '<', dtype = @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read_multiark(tmpdir, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(dtype) b = np.random.rand(10, 120).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:62: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float2/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.12319627, 0.55830852, 0.4198725 , ..., 0.07124419, 0.24528329,\n 0.1184302 ],\n [0.9334...2,\n 0.03204807],\n [0.52668458, 0.18028948, 0.74023809, ..., 0.91835441, 0.09324328,\n 0.76342507]])} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float2/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError ______________________________________________________________________ test_write_read_multiark[float64->] ______________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float3'), endian = '>', dtype = @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('dtype', [np.float32, np.float64]) def test_write_read_multiark(tmpdir, endian, dtype): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(dtype) b = np.random.rand(10, 120).astype(dtype) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:62: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float3/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.03944542, 0.77193936, 0.43734576, ..., 0.66652731, 0.00756347,\n 0.26708309],\n [0.2016... ,\n 0.9917585 ],\n [0.78933679, 0.20091672, 0.59070528, ..., 0.54900491, 0.95223431,\n 0.02300182]])} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_float3/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError _________________________________________________________________________ test_write_read_sequential[<] _________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_sequential___0'), endian = '<' @pytest.mark.parametrize('endian', ['<', '>']) def test_write_read_sequential(tmpdir, endian): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:85: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_sequential___0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.9329683 , 0.49766392, 0.07355864, ..., 0.16445483, 0.2163032 ,\n 0.0211493 ],\n [0.8061...275646],\n [0.5086685 , 0.30230552, 0.15834057, ..., 0.7522907 , 0.9502141 ,\n 0.17653736]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_sequential___0/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError _________________________________________________________________________ test_write_read_sequential[>] _________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_sequential___1'), endian = '>' @pytest.mark.parametrize('endian', ['<', '>']) def test_write_read_sequential(tmpdir, endian): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:85: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_sequential___1/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.19283496, 0.55607945, 0.58740455, ..., 0.6190917 , 0.74276245,\n 0.29386294],\n [0.8738...8079 ],\n [0.82100797, 0.72480553, 0.5745022 , ..., 0.6699211 , 0.07434456,\n 0.34855685]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_sequential___1/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError ____________________________________________________________________ test_write_read_multiark_sequential[<] _____________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_seque0'), endian = '<' @pytest.mark.parametrize('endian', ['<', '>']) def test_write_read_multiark_sequential(tmpdir, endian): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_seque0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.11848686, 0.0823758 , 0.82094216, ..., 0.7127775 , 0.17464672,\n 0.85083187],\n [0.9780...375236],\n [0.9847051 , 0.72792304, 0.69849455, ..., 0.24822065, 0.8943741 ,\n 0.01665717]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_seque0/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError ____________________________________________________________________ test_write_read_multiark_sequential[>] _____________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_seque1'), endian = '>' @pytest.mark.parametrize('endian', ['<', '>']) def test_write_read_multiark_sequential(tmpdir, endian): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath, endian=endian) tests/test_mat_ark.py:102: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_seque1/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.01262782, 0.9153292 , 0.90198165, ..., 0.08968648, 0.72189814,\n 0.55578023],\n [0.0632...94437 ],\n [0.6692686 , 0.09226122, 0.8720802 , ..., 0.5721618 , 0.50117314,\n 0.4046688 ]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_multiark_seque1/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError _____________________________________________________________________________ test_write_read_ascii _____________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_ascii0') def test_write_read_ascii(tmpdir): path = tmpdir.mkdir('test') a = np.random.rand(10, 10).astype(np.float32) b = np.random.rand(5, 35).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('a.scp').strpath, text=True) tests/test_mat_ark.py:123: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_ascii0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.43212757, 0.7546404 , 0.4246474 , 0.2279967 , 0.38793153,\n 0.06960681, 0.7133257 , 0.217179...25, 0.193877 , 0.4333235 ,\n 0.28211778, 0.7117296 , 0.5490963 , 0.5154121 , 0.8749333 ]],\n dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_ascii0/test/a.scp', append = False, text = True, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError ________________________________________________________________________ test_write_read_int32_vector[<] ________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_int32_vector__0'), endian = '<' @pytest.mark.parametrize('endian', ['<', '>']) def test_write_read_int32_vector(tmpdir, endian): path = tmpdir.mkdir('test') a = np.random.randint(1, 128, 10, dtype=np.int32) b = np.random.randint(1, 128, 10, dtype=np.int32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, scp=path.join('b.scp').strpath, > endian=endian) tests/test_mat_ark.py:140: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_int32_vector__0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([ 85, 54, 33, 42, 114, 125, 6, 67, 125, 2], dtype=int32), '\u3042\u3044\u3046\u3048\u304a': array([ 10, 31, 67, 47, 12, 55, 57, 116, 91, 21], dtype=int32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_int32_vector__0/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError ________________________________________________________________________ test_write_read_int32_vector[>] ________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_int32_vector__1'), endian = '>' @pytest.mark.parametrize('endian', ['<', '>']) def test_write_read_int32_vector(tmpdir, endian): path = tmpdir.mkdir('test') a = np.random.randint(1, 128, 10, dtype=np.int32) b = np.random.randint(1, 128, 10, dtype=np.int32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, scp=path.join('b.scp').strpath, > endian=endian) tests/test_mat_ark.py:140: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_int32_vector__1/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([ 50, 102, 62, 75, 73, 100, 101, 41, 127, 72], dtype=int32), '\u3042\u3044\u3046\u3048\u304a': array([ 78, 120, 110, 70, 98, 63, 51, 66, 30, 55], dtype=int32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_int32_vector__1/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError ______________________________________________________________________ test_write_read_int32_vector_ascii _______________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_int32_vector_a0') def test_write_read_int32_vector_ascii(tmpdir): path = tmpdir.mkdir('test') a = np.random.randint(1, 128, 10, dtype=np.int32) b = np.random.randint(1, 128, 10, dtype=np.int32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, scp=path.join('b.scp').strpath, > text=True) tests/test_mat_ark.py:162: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_int32_vector_a0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([ 76, 83, 92, 49, 120, 61, 100, 64, 84, 1], dtype=int32), '\u3042\u3044\u3046\u3048\u304a': array([ 11, 50, 70, 15, 88, 35, 73, 110, 14, 36], dtype=int32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_int32_vector_a0/test/b.scp', append = False, text = True, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError _________________________________________________________________________ test_write_read_compress[2-<] _________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_2___0'), compression_method = 2, endian = '<' @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('compression_method', [2, 3, 7]) def test_write_read_compress(tmpdir, compression_method, endian): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, scp=path.join('b.scp').strpath, compression_method=compression_method, > endian=endian) tests/test_mat_ark.py:199: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_2___0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[7.0628875e-01, 4.2391811e-03, 4.5245913e-01, ..., 7.9435807e-01,\n 4.7556299e-01, 8.3782315e-0...136691],\n [0.7210987 , 0.8292976 , 0.91712403, ..., 0.03051427, 0.32594725,\n 0.59675825]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_2___0/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = 2 def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError _________________________________________________________________________ test_write_read_compress[2->] _________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_2___1'), compression_method = 2, endian = '>' @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('compression_method', [2, 3, 7]) def test_write_read_compress(tmpdir, compression_method, endian): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, scp=path.join('b.scp').strpath, compression_method=compression_method, > endian=endian) tests/test_mat_ark.py:199: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_2___1/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.943823 , 0.7347321 , 0.5875692 , ..., 0.8413994 , 0.06398017,\n 0.849544 ],\n [0.2817...483725],\n [0.31913233, 0.06678754, 0.61648536, ..., 0.24105655, 0.14093482,\n 0.9267243 ]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_2___1/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = 2 def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError _________________________________________________________________________ test_write_read_compress[3-<] _________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_3___0'), compression_method = 3, endian = '<' @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('compression_method', [2, 3, 7]) def test_write_read_compress(tmpdir, compression_method, endian): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, scp=path.join('b.scp').strpath, compression_method=compression_method, > endian=endian) tests/test_mat_ark.py:199: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_3___0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.8979725 , 0.94522876, 0.05689498, ..., 0.44752967, 0.6289593 ,\n 0.06781002],\n [0.2894...052918],\n [0.96136963, 0.71883804, 0.22365892, ..., 0.368597 , 0.80707484,\n 0.6967472 ]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_3___0/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = 3 def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError _________________________________________________________________________ test_write_read_compress[3->] _________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_3___1'), compression_method = 3, endian = '>' @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('compression_method', [2, 3, 7]) def test_write_read_compress(tmpdir, compression_method, endian): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, scp=path.join('b.scp').strpath, compression_method=compression_method, > endian=endian) tests/test_mat_ark.py:199: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_3___1/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.15296805, 0.9832512 , 0.43418366, ..., 0.52208 , 0.17430428,\n 0.16527611],\n [0.7424...809394],\n [0.5417148 , 0.5517035 , 0.41819683, ..., 0.49676856, 0.35191232,\n 0.0319363 ]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_3___1/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = 3 def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError _________________________________________________________________________ test_write_read_compress[7-<] _________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_7___0'), compression_method = 7, endian = '<' @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('compression_method', [2, 3, 7]) def test_write_read_compress(tmpdir, compression_method, endian): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, scp=path.join('b.scp').strpath, compression_method=compression_method, > endian=endian) tests/test_mat_ark.py:199: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_7___0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.957983 , 0.70512265, 0.0355401 , ..., 0.06468503, 0.90083206,\n 0.44952092],\n [0.0673...768866],\n [0.5532768 , 0.59243184, 0.7580274 , ..., 0.7417296 , 0.3338873 ,\n 0.35484564]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_7___0/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = 7 def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError _________________________________________________________________________ test_write_read_compress[7->] _________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_7___1'), compression_method = 7, endian = '>' @pytest.mark.parametrize('endian', ['<', '>']) @pytest.mark.parametrize('compression_method', [2, 3, 7]) def test_write_read_compress(tmpdir, compression_method, endian): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, scp=path.join('b.scp').strpath, compression_method=compression_method, > endian=endian) tests/test_mat_ark.py:199: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_7___1/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[0.307926 , 0.23075503, 0.49764207, ..., 0.2845307 , 0.5620219 ,\n 0.6877927 ],\n [0.4375...64527 ],\n [0.56366223, 0.47104594, 0.9204645 , ..., 0.42280635, 0.10189573,\n 0.2767262 ]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_write_read_compress_7___1/test/b.scp', append = False, text = False, as_bytes = False, endian = '>', compression_method = 7 def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError _______________________________________________________________________________ test_append_mode ________________________________________________________________________________ tmpdir = local('/tmp/pytest-of-dpovey/pytest-1/test_append_mode0') def test_append_mode(tmpdir): path = tmpdir.mkdir('test') a = np.random.rand(1000, 120).astype(np.float32) b = np.random.rand(10, 120).astype(np.float32) origin = {u'\xcf,\xe9,\xe0': a, u'\u3042\u3044\u3046\u3048\u304a': b} kaldiio.save_ark(path.join('a.ark').strpath, origin, > scp=path.join('b.scp').strpath) tests/test_mat_ark.py:220: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ark = '/tmp/pytest-of-dpovey/pytest-1/test_append_mode0/test/a.ark' array_dict = {'\xcf,\xe9,\xe0': array([[5.7605296e-01, 4.7487631e-02, 6.5614831e-01, ..., 8.3323950e-01,\n 4.7280103e-01, 9.0374362e-0...378707],\n [0.6286977 , 0.00582741, 0.06016275, ..., 0.45188 , 0.9028227 ,\n 0.17181994]], dtype=float32)} scp = '/tmp/pytest-of-dpovey/pytest-1/test_append_mode0/test/b.scp', append = False, text = False, as_bytes = False, endian = '<', compression_method = None def save_ark(ark, array_dict, scp=None, append=False, text=False, as_bytes=False, endian='<', compression_method=None): """Write ark Args: ark (str or fd): array_dict (dict): scp (str or fd): append (bool): If True is specified, open the file with appendable mode text (bool): If True, saving in text ark format. as_bytes (bool): Save the value of the input array_dict as just a bytes string. endian (str): compression_method (int): """ if isinstance(ark, string_types): seekable = True # Maybe, never match with this elif not hasattr(ark, 'tell'): seekable = False else: try: ark.tell() seekable = True except Exception: seekable = False if scp is not None and not isinstance(ark, string_types): if not seekable: raise TypeError('scp file can be created only ' 'if the output ark file is a file or ' 'a seekable file descriptor.') # Write ark mode = 'ab' if append else 'wb' pos_list = [] with open_or_fd(ark, mode) as fd: if seekable: offset = fd.tell() else: offset = 0 size = 0 for key in array_dict: if PY3: encode_key = (key + ' ').encode() else: encode_key = (key + ' ').encode(py2_default_encoding) fd.write(encode_key) size += len(encode_key) pos_list.append(size) if as_bytes: byte = bytes(array_dict[key]) size += len(byte) fd.write(byte) else: data = array_dict[key] if isinstance(data, (list, tuple)): rate, array = data size += write_wav(fd, rate, array) elif text: size += write_array_ascii(fd, data, endian) else: size += write_array(fd, data, endian, compression_method) # Write scp mode = 'a' if append else 'w' if scp is not None: name = ark if isinstance(ark, string_types) else ark.name with open_or_fd(scp, mode) as fd: for key, position in zip(array_dict, pos_list): fd.write(key + u' ' + name + ':' + > str(position + offset) + '\n') E UnicodeEncodeError: 'ascii' codec can't encode character '\xcf' in position 0: ordinal not in range(128) kaldiio/matio.py:615: UnicodeEncodeError ----------- coverage: platform linux, python 3.5.3-final-0 ----------- Coverage HTML written to dir htmlcov ===================================================================== 31 failed, 78 passed in 3.85 seconds ======================================================================