音素转录中的语音声音矢量化
项目描述
SoundVectors
这个轻量级的Python包提供了一个将声音转换为音韵特征向量的强大工具。它在我们关于“将声音转换为音韵特征向量的生成系统”的研究中进行了详细描述。如果您使用这个包,我们恳请您引用这篇论文。
Rubehn, Arne, Jessica Nieder, and Johann-Mattis List (2024): A Generative System for Translating Sounds to Phonological Feature Vectors. +++
安装
您可以通过 pip
安装 soundvectors
包。
pip install soundvectors
运行评估的要求
如果您想重现我们论文中的评估,则需要一些额外的依赖项,这些依赖项不是核心包所需的。要安装它们,请克隆此存储库并运行
$ pip install -e .[dev]
您还需要从 Lexibank 下载评估数据。为此,请 cd
到 eval
目录并运行
soundvectors$ cd eval # cd into eval directory
eval$ make download
这将把 lexibank-analysed
数据集克隆到 eval
目录中。
运行评估脚本后,您可以通过运行以下命令从您的磁盘清除数据
eval$ make clear
用法
此包的核心是 SoundVectors
类,它将有效的 IPA 符号转换为相应的特征向量。推荐使用 SoundVectors
的方式是通过关键字参数 ts
传递一个可调用的转录系统
>>> from soundvectors import SoundVectors
>>> from pyclts import CLTS
>>> bipa = CLTS().bipa
>>> sv = SoundVectors(ts=bipa)
>>> sv.get_vec("t")
(1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0)
或者,您可以调用 get_vec
函数,传递一个 Sound
对象(由 soundvectors
派生)或根据 IPA 习惯描述声音的字符串。结果向量是相同的
>>> sv.get_vec("voiceless alveolar stop consonant") == sv.get_vec("t") == sv.get_vec(bipa["t"])
True
除了直接获取向量外,您还可以获取一个 FeatureBundle
对象
>>> feature_bundle = sv["t"] # set vectorize=False to return an object
>>> feature_bundle.cons # feature values can be retrieved by attribute access
1
>>> feature_bundle.as_set() # represent feature bundle as set of non-zero feature strings
frozenset({'-son', '-distr', '-cont', '-lab', '-lo', '-long', '+front', '-laryngeal', '-syl', '-delrel', '-voi', '-round', '+cons', '-velaric', '-dorsal', '-back', '-nas', '-pharyngeal', '+ant', '+cor', '-cg', '-sg', '-lat', '-hi'})
>>> str(feature_bundle) # string representation
'+cons,-syl,-son,-cont,-delrel,-lat,-nas,-voi,-sg,-cg,-pharyngeal,-laryngeal,+cor,-dorsal,-lab,-hi,-lo,-back,+front,0_tense,-round,-velaric,-long,+ant,-distr,0_strid,0_hitone,0_hireg,0_loreg,0_rising,0_falling,0_contour,0_backshift,0_frontshift,0_opening,0_closing,0_centering,0_longdistance,0_secondrounded'
>>> feature_bundle.as_vector() # raw vector representation (equal to the return value with vectorize=True)
(1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 0, -1, -1, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0)
最后,您可以调用 __call__
的 SoundVectors
对象来处理声音的 Collection
>> > sv(["s", "v"])
[(1, -1, -1, -1, ..., 0),
(1, -1, -1, 1, ..., 0)]
评估
eval
目录提供了用于论文中评估部分的代码。如果您想重现论文中报告的结果,请确保已安装依赖项并下载了数据(见上文)。然后,您可以简单地运行所有评估脚本 - 每个文件对应于论文中具有相同名称的子节
$ cd eval
$ python vector_similarities.py # 4.1 & 4.2
$ python equivalence_classes.py # 4.3
$ python distinctiveness.py # 4.4
$ python concordanceline.py # 4.4
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源分布
构建分布
soundvectors-1.0.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | dc6515e7a78c7d5f53715a37fc8076dd7f1c4cff05648986d90cab10c7892574 |
|
MD5 | 655cfbf61f2b8603f68fbbfc2fae7c0f |
|
BLAKE2b-256 | 48af3bb924320bc0eed8c4ed95f321a9b271154e89b160efad96bd75c6431c65 |
soundvectors-1.0-py2.py3-none-any.whl 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 6b2de24aba7369d97ec35c59bb73188d3072e0b0db76146de1b46f4ab977bd23 |
|
MD5 | 28afbad6ec6cba4beb98b23fa5bcf2d8 |
|
BLAKE2b-256 | 8766567fe022d3b3685ffa268e2769789b51f0449a483bca004cc7bfaf8889ca |