跳转到主要内容

音素转录中的语音声音矢量化

项目描述

SoundVectors

这个轻量级的Python包提供了一个将声音转换为音韵特征向量的强大工具。它在我们关于“将声音转换为音韵特征向量的生成系统”的研究中进行了详细描述。如果您使用这个包,我们恳请您引用这篇论文。

Rubehn, Arne, Jessica Nieder, and Johann-Mattis List (2024): A Generative System for Translating Sounds to Phonological Feature Vectors. +++

Build Status PyPI

安装

您可以通过 pip 安装 soundvectors 包。

pip install soundvectors

运行评估的要求

如果您想重现我们论文中的评估,则需要一些额外的依赖项,这些依赖项不是核心包所需的。要安装它们,请克隆此存储库并运行

$ pip install -e .[dev]

您还需要从 Lexibank 下载评估数据。为此,请 cdeval 目录并运行

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 (13.1 kB 查看哈希)

上传时间

构建分布

soundvectors-1.0-py2.py3-none-any.whl (10.5 kB 查看哈希)

上传时间 Python 2 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面