1{
2 lib,
3 stdenv,
4 replaceVars,
5 buildPythonPackage,
6 fetchPypi,
7 fetchpatch2,
8 joblib,
9 segments,
10 attrs,
11 dlinfo,
12 typing-extensions,
13 espeak-ng,
14 setuptools,
15 pytest,
16}:
17
18buildPythonPackage rec {
19 pname = "phonemizer";
20 version = "3.3.0";
21 pyproject = true;
22
23 build-system = [ setuptools ];
24
25 src = fetchPypi {
26 inherit pname version;
27 hash = "sha256-Xgw4Ei7/4LMxok5nSv8laHTs4WnXCpzxEgM3tW+OPQw=";
28 };
29
30 patches = [
31 (replaceVars ./backend-paths.patch {
32 libespeak = "${lib.getLib espeak-ng}/lib/libespeak-ng${stdenv.hostPlatform.extensions.sharedLibrary}";
33 # FIXME package festival
34 })
35 # This patch is needed for python3Packages.misaki. See https://github.com/thewh1teagle/espeakng-loader?tab=readme-ov-file#usage-with-phonemizer
36 # and https://github.com/bootphon/phonemizer/pull/191.
37 (fetchpatch2 {
38 name = "pr191-add-option-to-use-custom-espeak-data-path.patch";
39 url = "https://github.com/bootphon/phonemizer/commit/cc1db4bfaf688fdfb8275fd83d218f06411455e6.patch?full_index=1";
40 hash = "sha256-PMeX7A9BBVLS3Sk/Lum85GpJzKXM5tULTWSURq3MD8E=";
41 })
42 ];
43
44 propagatedBuildInputs = [
45 joblib
46 segments
47 attrs
48 dlinfo
49 typing-extensions
50 ];
51
52 # We tried to package festival, but were unable to get the backend running,
53 # so let's disable related tests.
54 doCheck = false;
55
56 meta = {
57 homepage = "https://github.com/bootphon/phonemizer";
58 changelog = "https://github.com/bootphon/phonemizer/blob/v${version}/CHANGELOG.md";
59 description = "Simple text to phones converter for multiple languages";
60 mainProgram = "phonemize";
61 license = lib.licenses.gpl3Plus;
62 maintainers = with lib.maintainers; [ bot-wxt1221 ];
63 };
64}