Closed donand closed 1 year ago
Hi, indeed this may be problematic. We must play with this in order to detect if comma or point are surrounded by numbers.
@donand With the most recently merged PR, it's now possible to achieve what you're after by defining the punctuation with regular expressions.
The default marks are defined as the string ;:,.!?¡¿—…"«»“”
If instead you set the marks to the regular expression [;:!?¡¿—…"«»“”]|[,.](?!\d)
commas and periods followed by a digit won't be treated as punctuation.
phonemize("4.16 meters", language='en-us', backend='espeak', preserve_punctuation=True, with_stress=True, language_switch='remove-flags', punctuation_marks=re.compile(r'[;:!?¡¿—…"«»“”]|[,.](?!\d)'))
Or, via the command line, with the new parameter --punctuation-marks-is-regex
:
echo "4.16 meters" | phonemize --preserve-punctuation --with-stress --language-switch remove-flags --punctuation-marks '[;:!?¡¿—…"«»“”]|[,.](?!\d)' --punctuation-marks-is-regex
returns
fˈoːɹ pɔɪnt wˈʌn sˈɪks mˈiːɾɚz
Describe the bug The library does not transcribe commas and points inside numbers, but it considers them as normal punctuation.
Phonemizer version
System
To reproduce Italian
English
Expected behavior A clear and concise description of what you expected to happen. Italian
English
Additional context If I set
preserve_punctuation=False
the comma or the point inside the number is just dropped and not transcribed.