scriptconv-copyleft 0.6.0a1__tar.gz → 0.7.1a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/PKG-INFO +1 -1
  2. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/pyproject.toml +1 -0
  3. scriptconv_copyleft-0.7.1a1/scriptconv_copyleft/phonemizers/espeak_es_419.json +11 -0
  4. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/mul.py +9 -0
  5. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/tiny_vanya.py +60 -3
  6. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/version.py +2 -2
  7. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft.egg-info/PKG-INFO +1 -1
  8. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft.egg-info/SOURCES.txt +2 -0
  9. scriptconv_copyleft-0.7.1a1/tests/test_espeak_es_americas.py +36 -0
  10. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_tiny_vanya.py +56 -0
  11. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/LICENSE +0 -0
  12. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/README.md +0 -0
  13. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/__init__.py +0 -0
  14. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/__init__.py +0 -0
  15. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/__init__.py +0 -0
  16. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/kog2p/COPYING +0 -0
  17. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/kog2p/LICENSE.md +0 -0
  18. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/kog2p/__init__.py +0 -0
  19. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/kog2p/rulebook.txt +0 -0
  20. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/LICENSE +0 -0
  21. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/MODEL_LICENSE.md +0 -0
  22. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/NOTICE +0 -0
  23. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/__init__.py +0 -0
  24. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/codemix.py +0 -0
  25. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/data/LICENSE +0 -0
  26. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/data/en_fast_lexicon.json.gz +0 -0
  27. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/data/ne_heteronyms.tsv.gz +0 -0
  28. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/data/ne_lexicon.tsv.gz +0 -0
  29. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/frontend.py +0 -0
  30. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/inventory.py +0 -0
  31. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/pawp/nepali_rules.py +0 -0
  32. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/reginute/COPYING +0 -0
  33. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/reginute/LICENSE +0 -0
  34. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/reginute/SOURCE +0 -0
  35. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/reginute/lt_kirciai.tsv +0 -0
  36. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/reginute/lt_kreipiniai.tsv +0 -0
  37. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/reginute/lt_raides.tsv +0 -0
  38. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/LICENSE +0 -0
  39. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/NOTICE +0 -0
  40. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/__init__.py +0 -0
  41. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/bilingual.py +0 -0
  42. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/LICENSE +0 -0
  43. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/LICENSE.ruaccent +0 -0
  44. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/caps_words.json.gz +0 -0
  45. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/homograph_defaults.json.gz +0 -0
  46. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/homograph_model.json.gz +0 -0
  47. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/pronunciations.json.gz +0 -0
  48. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/stress_forms.json.gz +0 -0
  49. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/stress_variants.json.gz +0 -0
  50. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/yo_words.json.gz +0 -0
  51. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/text.py +0 -0
  52. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/eu.py +0 -0
  53. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/fa.py +0 -0
  54. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/gl.py +0 -0
  55. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/he.py +0 -0
  56. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/ja.py +0 -0
  57. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/ja_prosody.py +0 -0
  58. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/ko.py +0 -0
  59. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/lt.py +0 -0
  60. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/pawp.py +0 -0
  61. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/phonemizers/th.py +0 -0
  62. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft/readings.py +0 -0
  63. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft.egg-info/dependency_links.txt +0 -0
  64. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft.egg-info/requires.txt +0 -0
  65. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/scriptconv_copyleft.egg-info/top_level.txt +0 -0
  66. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/setup.cfg +0 -0
  67. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_docs_examples.py +0 -0
  68. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_espeak_acute_stress.py +0 -0
  69. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_espeak_french_english_switch.py +0 -0
  70. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_espeak_get_lang_case.py +0 -0
  71. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_espeak_long_line.py +0 -0
  72. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_espeak_lt_accent.py +0 -0
  73. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_espeak_nul_byte.py +0 -0
  74. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_g2pfa_eraab.py +0 -0
  75. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_hebrew_ipa.py +0 -0
  76. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_lang_default_region.py +0 -0
  77. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_match_lang_direction.py +0 -0
  78. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_match_lang_preferred_value.py +0 -0
  79. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_misaki_en_alphabet.py +0 -0
  80. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_misaki_ja_reader.py +0 -0
  81. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_misaki_vi.py +0 -0
  82. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_misaki_zh_zero.py +0 -0
  83. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_openjtalk_prosody.py +0 -0
  84. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_pawp.py +0 -0
  85. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_phonemizers_base.py +0 -0
  86. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_phonemizers_cjk_ar.py +0 -0
  87. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_phonemizers_friendly_import_errors.py +0 -0
  88. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_phonemizers_identity.py +0 -0
  89. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_phonemizers_misaki_british.py +0 -0
  90. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_phonemizers_punctuation.py +0 -0
  91. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_readings.py +0 -0
  92. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_tltk.py +0 -0
  93. {scriptconv_copyleft-0.6.0a1 → scriptconv_copyleft-0.7.1a1}/tests/test_transphone_extra_declares_auto_installs.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptconv-copyleft
3
- Version: 0.6.0a1
3
+ Version: 0.7.1a1
4
4
  Summary: scriptconv phonemizer backends whose code or dependencies are copyleft (GPL, LGPL, AGPL)
5
5
  Author-email: TigreGotico <contact@tigregotico.com>
6
6
  License-Expression: Apache-2.0 AND GPL-3.0-only AND GPL-3.0-or-later AND CC-BY-4.0 AND MIT
@@ -65,6 +65,7 @@ include = ["scriptconv_copyleft*"]
65
65
  version = {attr = "scriptconv_copyleft.version.__version__"}
66
66
 
67
67
  [tool.setuptools.package-data]
68
+ "scriptconv_copyleft.phonemizers" = ["espeak_es_419.json"]
68
69
  "scriptconv_copyleft.phonemizers._vendored.kog2p" = ["rulebook.txt", "LICENSE.md", "COPYING"]
69
70
  "scriptconv_copyleft.phonemizers._vendored" = ["reginute/*"]
70
71
  "scriptconv_copyleft.phonemizers._vendored.pawp" = ["LICENSE", "NOTICE", "MODEL_LICENSE.md", "data/*"]
@@ -0,0 +1,11 @@
1
+ {
2
+ "source": "UN M.49 Standard country or area codes for statistical use, region 419 Latin America and the Caribbean (https://unstats.un.org/unsd/methodology/m49/), plus US for es-US",
3
+ "voice": "es-419",
4
+ "regions": [
5
+ "AI", "AG", "AW", "BS", "BB", "BQ", "VG", "KY", "CU", "CW", "DM", "DO", "GD", "GP", "HT", "JM",
6
+ "MQ", "MS", "PR", "BL", "KN", "LC", "MF", "VC", "SX", "TT", "TC", "VI",
7
+ "BZ", "CR", "SV", "GT", "HN", "MX", "NI", "PA",
8
+ "AR", "BO", "BV", "BR", "CL", "CO", "EC", "FK", "GF", "GY", "PY", "PE", "GS", "SR", "UY", "VE",
9
+ "US"
10
+ ]
11
+ }
@@ -1,5 +1,6 @@
1
1
  """multilingual phonemizers"""
2
2
 
3
+ import json
3
4
  import os
4
5
  import re
5
6
  import subprocess
@@ -20,6 +21,12 @@ _HK_CANTONESE = frozenset({
20
21
  })
21
22
 
22
23
 
24
+ with open(os.path.join(os.path.dirname(__file__), "espeak_es_419.json"), encoding="utf-8") as _f:
25
+ _ES_419 = json.load(_f)
26
+ # Spanish of the Americas reads with the seseo voice es-419; plain es is Castilian.
27
+ _ESPEAK_ES_419 = frozenset(f"es-{r.lower()}" for r in _ES_419["regions"])
28
+
29
+
23
30
  def _is_hk_cantonese(lang: str) -> bool:
24
31
  return lang.lower().replace("_", "-") in _HK_CANTONESE
25
32
 
@@ -287,6 +294,8 @@ class EspeakPhonemizer(BasePhonemizer):
287
294
  tag = target_lang.lower().replace("_", "-")
288
295
  if tag in ZH_ALIASES:
289
296
  return ZH_ALIASES[tag]
297
+ if tag in _ESPEAK_ES_419:
298
+ return _ES_419["voice"]
290
299
  if tag in cls.ESPEAK_LANGS:
291
300
  return tag
292
301
  if tag.split("-")[0] in cls.ESPEAK_LANGS:
@@ -37,12 +37,13 @@ Data in ``_vendored/tiny_vanya/data``, read on first use:
37
37
  from __future__ import annotations
38
38
 
39
39
  from functools import cached_property
40
+ from typing import Iterator
40
41
 
41
- from scriptconv.phonemizers.base import BasePhonemizer, _check_alphabet
42
+ from scriptconv.phonemizers.base import CLAUSE_PUNCTUATION, BasePhonemizer, Segment, _check_alphabet
42
43
  from scriptconv.phonemizers.enums import Alphabet
43
44
 
44
45
  from scriptconv_copyleft.phonemizers._vendored.tiny_vanya import bilingual, text
45
- from scriptconv_copyleft.phonemizers._vendored.tiny_vanya.text import Phonemized
46
+ from scriptconv_copyleft.phonemizers._vendored.tiny_vanya.text import NothingToPronounce, Phonemized
46
47
 
47
48
  __all__ = ["TinyVanyaPhonemizer", "Phonemized", "SYMBOLS"]
48
49
 
@@ -50,6 +51,8 @@ SYMBOLS = text.BILINGUAL_SYMBOLS
50
51
  """The 116 symbols of the Tiny Vanya models, in id order."""
51
52
 
52
53
  _STRESS_MARK = {1: "ˈ", 2: "ˌ"}
54
+ _CLAUSE_MARKS = frozenset(CLAUSE_PUNCTUATION.values())
55
+ _SENTENCE_MARKS = frozenset(".?!")
53
56
 
54
57
 
55
58
  class TinyVanyaPhonemizer(BasePhonemizer):
@@ -65,13 +68,19 @@ class TinyVanyaPhonemizer(BasePhonemizer):
65
68
  pronunciations: a pronunciation table ``{"defaults": ..., "variants": ...}``,
66
69
  as in the ``pronunciations`` of a Tiny Vanya model config. ``None``
67
70
  reads the table of ``onnx/m1.json`` that ships with this package.
71
+ tokens: :meth:`phonemize_segments` yields the Tiny Vanya tokens, not
72
+ IPA: one bounded segment per clause, from ``<bos>`` to ``<eos>``,
73
+ with ``ids`` and ``stress`` streams. The stress is 0 (none),
74
+ 1 (primary) or 2 (secondary) for each symbol.
68
75
  """
69
76
 
70
77
  engine_distribution = "espyak"
71
78
 
72
- def __init__(self, alphabet: Alphabet = Alphabet.IPA, pronunciations: dict | None = None):
79
+ def __init__(self, alphabet: Alphabet = Alphabet.IPA, pronunciations: dict | None = None,
80
+ tokens: bool = False):
73
81
  _check_alphabet(self, alphabet, [Alphabet.IPA])
74
82
  super().__init__(alphabet)
83
+ self.tokens_mode = tokens
75
84
  if pronunciations is not None:
76
85
  self.pronunciations = pronunciations
77
86
 
@@ -97,3 +106,51 @@ class TinyVanyaPhonemizer(BasePhonemizer):
97
106
  return " ".join(
98
107
  "".join(_STRESS_MARK.get(tokens.stress[i], "") + tokens.symbols[i] for i in range(start, end))
99
108
  for start, end in tokens.words)
109
+
110
+ def phonemize_segments(self, text: str, lang: str) -> Iterator[Segment]:
111
+ """The segments of *text*; with ``tokens=True``, the tokens of each clause.
112
+
113
+ A clause ends after a run of ``, . ? ! ; :`` that follows a sound. Its mark is the first
114
+ mark of the run, and it ends a sentence when the run holds ``.``,
115
+ ``?`` or ``!``. The last clause ends a sentence. The text is read
116
+ whole once; text with no word to read gives no segment.
117
+ """
118
+ if not self.tokens_mode:
119
+ yield from super().phonemize_segments(text, lang)
120
+ return
121
+ try:
122
+ whole = self.phonemize_tokens(text, lang)
123
+ except NothingToPronounce:
124
+ return
125
+ symbols = whole.symbols
126
+ last = len(symbols) - 1
127
+ start = index = 1
128
+ sound = False
129
+ clauses = []
130
+ while index < last:
131
+ if symbols[index] == "<unk>" or symbols[index][0] != "<" and any(c.isalpha() for c in symbols[index]):
132
+ sound = True
133
+ elif sound and symbols[index] in _CLAUSE_MARKS:
134
+ end = index
135
+ while end < last and symbols[end] in _CLAUSE_MARKS:
136
+ end += 1
137
+ clauses.append([start, end, symbols[index], bool(_SENTENCE_MARKS.intersection(symbols[index:end]))])
138
+ start = index = end + (end < last and symbols[end] == "<sp>")
139
+ sound = False
140
+ continue
141
+ index += 1
142
+ if start < last:
143
+ clauses.append([start, last, None, True])
144
+ if clauses:
145
+ clauses[-1][3] = True
146
+ for start, end, mark, ends_sentence in clauses:
147
+ yield Segment((symbols[0], *symbols[start:end], symbols[-1]), mark, ends_sentence,
148
+ {"ids": (whole.ids[0], *whole.ids[start:end], whole.ids[-1]),
149
+ "stress": (0, *whole.stress[start:end], 0)},
150
+ bounded=True)
151
+
152
+ def word_break(self) -> Segment:
153
+ """``<sp>`` with its id with ``tokens=True``, else a space."""
154
+ if self.tokens_mode:
155
+ return Segment(("<sp>",), streams={"ids": (SYMBOLS.index("<sp>"),), "stress": (0,)})
156
+ return super().word_break()
@@ -1,7 +1,7 @@
1
1
  # START_VERSION_BLOCK
2
2
  VERSION_MAJOR = 0
3
- VERSION_MINOR = 6
4
- VERSION_BUILD = 0
3
+ VERSION_MINOR = 7
4
+ VERSION_BUILD = 1
5
5
  VERSION_ALPHA = 1
6
6
  # END_VERSION_BLOCK
7
7
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptconv-copyleft
3
- Version: 0.6.0a1
3
+ Version: 0.7.1a1
4
4
  Summary: scriptconv phonemizer backends whose code or dependencies are copyleft (GPL, LGPL, AGPL)
5
5
  Author-email: TigreGotico <contact@tigregotico.com>
6
6
  License-Expression: Apache-2.0 AND GPL-3.0-only AND GPL-3.0-or-later AND CC-BY-4.0 AND MIT
@@ -10,6 +10,7 @@ scriptconv_copyleft.egg-info/dependency_links.txt
10
10
  scriptconv_copyleft.egg-info/requires.txt
11
11
  scriptconv_copyleft.egg-info/top_level.txt
12
12
  scriptconv_copyleft/phonemizers/__init__.py
13
+ scriptconv_copyleft/phonemizers/espeak_es_419.json
13
14
  scriptconv_copyleft/phonemizers/eu.py
14
15
  scriptconv_copyleft/phonemizers/fa.py
15
16
  scriptconv_copyleft/phonemizers/gl.py
@@ -61,6 +62,7 @@ scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/stress_variants.json.g
61
62
  scriptconv_copyleft/phonemizers/_vendored/tiny_vanya/data/yo_words.json.gz
62
63
  tests/test_docs_examples.py
63
64
  tests/test_espeak_acute_stress.py
65
+ tests/test_espeak_es_americas.py
64
66
  tests/test_espeak_french_english_switch.py
65
67
  tests/test_espeak_get_lang_case.py
66
68
  tests/test_espeak_long_line.py
@@ -0,0 +1,36 @@
1
+ """Spanish of the Americas reads with the espeak-ng voice es-419 (seseo), not Castilian es."""
2
+ import shutil
3
+
4
+ import pytest
5
+
6
+ from scriptconv.phonemizers.enums import Phonemizer
7
+ from scriptconv.phonemizers.registry import get_phonemizer
8
+
9
+ from scriptconv_copyleft.phonemizers.mul import EspeakPhonemizer
10
+
11
+ AMERICAS = ["es-CO", "es-MX", "es-AR", "es-US", "es_cl", "ES-PR"]
12
+
13
+
14
+ @pytest.mark.parametrize("tag", AMERICAS)
15
+ def test_americas_tag_resolves_to_es_419(tag):
16
+ assert EspeakPhonemizer.get_lang(tag) == "es-419"
17
+
18
+
19
+ @pytest.mark.parametrize("tag", ["es-ES", "es", "es-GQ"])
20
+ def test_european_and_african_tags_stay_castilian(tag):
21
+ assert EspeakPhonemizer.get_lang(tag) == "es"
22
+
23
+
24
+ @pytest.mark.skipif(shutil.which("espeak-ng") is None, reason="needs the espeak-ng binary")
25
+ @pytest.mark.parametrize("tag", ["es-CO", "es-MX", "es-AR", "es-US"])
26
+ def test_americas_tag_has_no_theta(tag):
27
+ ph = get_phonemizer(Phonemizer.ESPEAK)
28
+ assert ph.phonemize_string("cielo azul zapato", tag) == "sjˈelo asˈul sapˈato"
29
+ assert ph.identity(tag).lang == "es-419"
30
+
31
+
32
+ @pytest.mark.skipif(shutil.which("espeak-ng") is None, reason="needs the espeak-ng binary")
33
+ def test_es_es_keeps_theta():
34
+ ph = get_phonemizer(Phonemizer.ESPEAK)
35
+ assert ph.phonemize_string("cielo azul zapato", "es-ES") == "θjˈelo aθˈul θapˈato"
36
+ assert ph.identity("es-ES").lang == "es"
@@ -81,3 +81,59 @@ def test_without_numpy_english_falls_back_to_espyak(monkeypatch):
81
81
  assert tokens.symbols[0] == "<bos>" and tokens.symbols[-1] == "<eos>"
82
82
  assert "<unk>" not in tokens.symbols
83
83
  assert "w" in tokens.symbols
84
+
85
+
86
+ def _parity_row(text):
87
+ return next(row for row in ROWS if row["text"] == text)
88
+
89
+
90
+ def test_tokens_mode_yields_the_tiny_vanya_ids_and_stress():
91
+ row = _parity_row("Привет, как дела?")
92
+ whole = TinyVanyaPhonemizer().phonemize_tokens(row["text"], "ru")
93
+ segments = list(TinyVanyaPhonemizer(tokens=True).phonemize_segments(row["text"], "ru"))
94
+ bos, eos = row["ids"][0], row["ids"][-1]
95
+ cut = row["ids"].index(SYMBOLS.index(",")) + 1
96
+ assert [s.streams["ids"] for s in segments] == [
97
+ (bos, *row["ids"][1:cut], eos), (bos, *row["ids"][cut:-1], eos)]
98
+ assert [s.streams["stress"] for s in segments] == [
99
+ (0, *row["stress"][1:cut], 0), (0, *row["stress"][cut:-1], 0)]
100
+ assert [i for s in segments for i in s.streams["ids"][1:-1]] == list(whole.ids[1:-1])
101
+ assert [s.phonemes for s in segments] == [tuple(SYMBOLS[i] for i in s.streams["ids"]) for s in segments]
102
+
103
+
104
+ def test_tokens_mode_frames_each_clause():
105
+ segments = list(TinyVanyaPhonemizer(tokens=True).phonemize_segments("Да, конечно. Нет", "ru"))
106
+ assert [s.phonemes[0] for s in segments] == ["<bos>"] * 3
107
+ assert [s.phonemes[-1] for s in segments] == ["<eos>"] * 3
108
+ assert [s.mark for s in segments] == [",", ".", None]
109
+ assert [s.ends_sentence for s in segments] == [False, True, True]
110
+ assert all(s.bounded for s in segments)
111
+ assert [s.phonemes[-2] for s in segments[:2]] == [",", "."]
112
+
113
+
114
+ def test_without_tokens_the_segments_are_ipa():
115
+ vanya = TinyVanyaPhonemizer()
116
+ segments = list(vanya.phonemize_segments("Привет! Как дела?", "ru"))
117
+ assert ["".join(s.phonemes) for s in segments] == ["prʲivʲˈet", "kˈɑk dʲiɭˈɑ"]
118
+ assert not any(s.bounded for s in segments)
119
+
120
+
121
+ def test_tokens_mode_last_clause_ends_a_sentence():
122
+ segments = list(TinyVanyaPhonemizer(tokens=True).phonemize_segments("Привет,", "ru"))
123
+ assert [(s.mark, s.ends_sentence) for s in segments] == [(",", True)]
124
+
125
+
126
+ def test_tokens_mode_mark_is_the_first_of_the_run():
127
+ segments = list(TinyVanyaPhonemizer(tokens=True).phonemize_segments("Ну... да?!", "ru"))
128
+ assert segments[-1].mark == "?"
129
+
130
+
131
+ def test_tokens_mode_marks_only_give_no_segment():
132
+ assert list(TinyVanyaPhonemizer(tokens=True).phonemize_segments("?!", "ru")) == []
133
+
134
+
135
+ @pytest.mark.parametrize("text, marks", [("! Привет", [None]), ("— Привет, мир!", [",", "!"])])
136
+ def test_tokens_mode_leading_marks_stay_with_the_next_clause(text, marks):
137
+ segments = list(TinyVanyaPhonemizer(tokens=True).phonemize_segments(text, "ru"))
138
+ assert [s.mark for s in segments] == marks
139
+ assert all("p" in s.phonemes or "mʲ" in s.phonemes for s in segments)