Parameters: phones – a string containing space-separated CMUdict phones
Returns: integer count of syllables in list of phones
However, phones_for_word returns a list, not a string (Python 2.7.12, pronouncing==0.1.3):
>>> import pronouncing
>>> phones = pronouncing.phones_for_word("literally")
>>> phones
[u'L IH1 T ER0 AH0 L IY0', u'L IH1 T R AH0 L IY0']
>>> pronouncing.syllable_count(phones)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/pronouncing/__init__.py", line 72, in syllable_count
return len(stresses(phones))
File "/usr/local/lib/python2.7/site-packages/pronouncing/__init__.py", line 108, in stresses
return re.sub(r"[^012]", "", s)
File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 155, in sub
return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or buffer
>>> pronouncing.syllable_count(phones[0])
4
https://pronouncing.readthedocs.io/en/latest/pronouncing.html#pronouncing.syllable_count says:
However,
phones_for_word
returns a list, not a string (Python 2.7.12, pronouncing==0.1.3):The
syllable_count
examples in https://pronouncing.readthedocs.io/en/latest/tutorial.html#counting-syllables look fine.