bootphon / phonemizer

Simple text to phones converter for multiple languages
https://bootphon.github.io/phonemizer/
GNU General Public License v3.0
1.15k stars 163 forks source link

with_stress=True generates "unexpected keyword argument" error #150

Closed RiccaDS closed 1 year ago

RiccaDS commented 1 year ago

Describe the bug When launching the code phonemized = backend.phonemize([to_print], separator=separator, with_stress=True) I get the following error TypeError: phonemize() got an unexpected keyword argument 'with_stress'

Phonemizer version

phonemizer-3.2.1
available backends: espeak-ng-1.50, segments-2.2.1

System Linux mint Cinnamon, Python 3.9.2

To reproduce

from phonemizer.backend import EspeakBackend
from phonemizer.separator import Separator
backend = EspeakBackend('it')
separator = Separator(phone="-", word="|")

phonemized = backend.phonemize(["hello","world"], separator=separator, with_stress=True)
print(phonemized)

Expected behavior I expect no error and output of the phones list with phones stresses.

mmmaat commented 1 year ago

Hi, the ẁith_stress` argument must be specified in the backend init, not the phonemize method:

In [3]: from phonemizer.backend import EspeakBackend 
   ...: from phonemizer.separator import Separator 
   ...: backend = EspeakBackend('it', with_stress=True) 
   ...: separator = Separator(phone="-", word="|") 
   ...: phonemized = backend.phonemize(["hello","world"], separator=separator)

See also here. The documentation should be clearer.

RiccaDS commented 1 year ago

Yes, works great thanks. Forgive me, I occasionally code on python but I am not very expert on the OO part; so the docs are a bit complicated to me on occasions. Also I was very tired. So I don't know if the docs are ok or not.