Skip to content

Commit

Permalink
reformat with isort and black
Browse files Browse the repository at this point in the history
  • Loading branch information
synodriver committed Aug 12, 2022
1 parent a9873b8 commit 89843b3
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 32 deletions.
6 changes: 3 additions & 3 deletions pyopenjtalk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import tarfile

try:
from .version import __version__ # NOQA
from pyopenjtalk.version import __version__ # NOQA
except ImportError:
raise ImportError("BUG: version.py doesn't exist. Please file a bug report.")

from .htsengine import HTSEngine
from .openjtalk import OpenJTalk
from pyopenjtalk.htsengine import HTSEngine
from pyopenjtalk.openjtalk import OpenJTalk

# Dictionary directory
# defaults to the package directory where the dictionary will be automatically downloaded
Expand Down
20 changes: 11 additions & 9 deletions pyopenjtalk/htsengine.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
import numpy as np

cimport numpy as np

np.import_array()

cimport cython
from cpython.mem cimport PyMem_Free, PyMem_Malloc
from cython.parallel cimport prange
from cpython.mem cimport PyMem_Malloc, PyMem_Free
from libc.stdint cimport uint8_t

from pyopenjtalk.htsengine cimport HTS_Engine
from pyopenjtalk.htsengine cimport (
HTS_Engine_initialize, HTS_Engine_load, HTS_Engine_clear, HTS_Engine_refresh,
HTS_Engine_get_sampling_frequency, HTS_Engine_get_fperiod,
HTS_Engine_set_speed, HTS_Engine_add_half_tone,
HTS_Engine_synthesize_from_strings,
HTS_Engine_get_generated_speech, HTS_Engine_get_nsamples
)
from pyopenjtalk.htsengine cimport (HTS_Engine, HTS_Engine_add_half_tone,
HTS_Engine_clear, HTS_Engine_get_fperiod,
HTS_Engine_get_generated_speech,
HTS_Engine_get_nsamples,
HTS_Engine_get_sampling_frequency,
HTS_Engine_initialize, HTS_Engine_load,
HTS_Engine_refresh, HTS_Engine_set_speed,
HTS_Engine_synthesize_from_strings)


@cython.final
@cython.no_gc
Expand Down
23 changes: 16 additions & 7 deletions pyopenjtalk/openjtalk.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,34 @@
# cython: c_string_type=unicode, c_string_encoding=ascii, cdivision=True

from libc.stdint cimport uint8_t

import numpy as np

cimport numpy as np

np.import_array()

cimport cython
from cpython.bytes cimport PyBytes_AS_STRING

from pyopenjtalk.openjtalk.mecab cimport Mecab, Mecab_initialize, Mecab_load, Mecab_analysis
from pyopenjtalk.openjtalk.mecab cimport Mecab_get_feature, Mecab_get_size, Mecab_refresh, Mecab_clear
from pyopenjtalk.openjtalk.njd cimport NJD, NJD_initialize, NJD_refresh, NJD_print, NJD_clear
from pyopenjtalk.openjtalk cimport njd as _njd
from pyopenjtalk.openjtalk.jpcommon cimport JPCommon, JPCommon_initialize,JPCommon_make_label
from pyopenjtalk.openjtalk.jpcommon cimport JPCommon_get_label_size, JPCommon_get_label_feature
from pyopenjtalk.openjtalk.jpcommon cimport JPCommon_refresh, JPCommon_clear
from pyopenjtalk.openjtalk cimport njd2jpcommon
from pyopenjtalk.openjtalk.text2mecab cimport text2mecab
from pyopenjtalk.openjtalk.jpcommon cimport (JPCommon, JPCommon_clear,
JPCommon_get_label_feature,
JPCommon_get_label_size,
JPCommon_initialize,
JPCommon_make_label,
JPCommon_refresh)
from pyopenjtalk.openjtalk.mecab cimport (Mecab, Mecab_analysis, Mecab_clear,
Mecab_get_feature, Mecab_get_size,
Mecab_initialize, Mecab_load,
Mecab_refresh)
from pyopenjtalk.openjtalk.mecab2njd cimport mecab2njd
from pyopenjtalk.openjtalk.njd cimport (NJD, NJD_clear, NJD_initialize,
NJD_print, NJD_refresh)
from pyopenjtalk.openjtalk.njd2jpcommon cimport njd2jpcommon
from pyopenjtalk.openjtalk.text2mecab cimport text2mecab


cdef inline str njd_node_get_string(_njd.NJDNode* node):
return (<bytes>(_njd.NJDNode_get_string(node))).decode("utf-8")
Expand Down
1 change: 1 addition & 0 deletions pyopenjtalk/openjtalk/jpcommon.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from libc.stdio cimport FILE


cdef extern from "jpcommon.h" nogil:
cdef cppclass JPCommonNode:
char *pron
Expand Down
3 changes: 2 additions & 1 deletion pyopenjtalk/openjtalk/mecab2njd.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# distutils: language = c++
# cython: language_level=3

from .njd cimport NJD
from pyopenjtalk.openjtalk.njd cimport NJD


cdef extern from "mecab2njd.h" nogil:
void mecab2njd(NJD * njd, char **feature, int size);
1 change: 1 addition & 0 deletions pyopenjtalk/openjtalk/njd.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from libc.stdio cimport FILE


cdef extern from "njd.h" nogil:
cdef cppclass NJDNode:
char *string
Expand Down
5 changes: 3 additions & 2 deletions pyopenjtalk/openjtalk/njd2jpcommon.pxd
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# distutils: language = c++
# cython: language_level=3

from .jpcommon cimport JPCommon
from .njd cimport NJD
from pyopenjtalk.openjtalk.jpcommon cimport JPCommon
from pyopenjtalk.openjtalk.njd cimport NJD


cdef extern from "njd2jpcommon.h" nogil:
void njd2jpcommon(JPCommon * jpcommon, NJD * njd)
19 changes: 9 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import subprocess
import sys
import platform
import shutil
import subprocess
import sys
from distutils.errors import DistutilsExecError
from distutils.spawn import spawn
from distutils.version import LooseVersion
Expand All @@ -14,15 +14,15 @@
import numpy as np
import setuptools.command.build_py
import setuptools.command.develop
import six
from setuptools import Extension, find_packages, setup

import six
if six.PY2:
from urllib import urlretrieve
else:
from urllib.request import urlretrieve
import tarfile

import tarfile

platform_is_windows = sys.platform == "win32"

Expand Down Expand Up @@ -88,19 +88,19 @@ def build_extensions(self):
system = platform.system()
if system == "Windows":
extra_compile_args = []
extra_link_args = ['/openmp']
extra_link_args = ["/openmp"]
elif system == "Linux":
extra_compile_args = ['-fopenmp']
extra_link_args = ['-fopenmp']
extra_compile_args = ["-fopenmp"]
extra_link_args = ["-fopenmp"]
elif system == "Darwin":
os.system("brew install llvm libomp")
os.system("brew install clang-omp")
# os.environ["CPP"] = "/usr/local/opt/llvm/bin/clang"
extra_compile_args = ["-Xpreprocessor", "-fopenmp"]
extra_link_args = ["-Xpreprocessor", "-fopenmp"]
else:
extra_compile_args = ['-fopenmp']
extra_link_args = ['-fopenmp']
extra_compile_args = ["-fopenmp"]
extra_link_args = ["-fopenmp"]


# Workaround for `distutils.spawn` problem on Windows python < 3.9
Expand Down Expand Up @@ -171,7 +171,6 @@ def escape_macros(macros):
src_top = join("lib", "open_jtalk", "src")



# extract dic
filename = "dic.tar.gz"
print(f"Downloading: {_DICT_URL}")
Expand Down

0 comments on commit 89843b3

Please sign in to comment.