python 3语音库。
pyphonetics的Python项目详细描述
pyaponics是一个用于语音算法的Python 3库现在,实现并支持以下算法:
- Soundex
- Metaphone
- Refined Soundex
- Fuzzy Soundex
- Lein
- Matching Rating Approach
今后还会增加更多。
安装
该模块在PyPI中可用,只需使用pip install pyphonics
用法
>>> from pyphonetics import Soundex >>> soundex = Soundex() >>> soundex.phonetics('Rupert') 'R163' >>> soundex.phonetics('Robert') 'R163' >>> soundex.sounds_like('Robert', 'Rupert') True
相同的API适用于每个算法,例如:
>>> from pyphonetics import Metaphone >>> metaphone = Metaphone() >>> metaphone.phonetics('discrimination') 'TSKRMNXN'
您还可以使用距离(word1,word2,metric='levenshtein')方法来查找两个语音表示之间的距离
>>> from pyphonetics import RefinedSoundex >>> rs = RefinedSoundex() >>> rs.distance('Rupert', 'Robert') 0 >>> rs.distance('assign', 'assist', metric='hamming') 2
学分
该模块主要基于Talisman.js(https://github.com/Yomguithereal/talisman)节点NLP库中语音算法的实现