MMS-MSG是用于产生语音混合物的高度模块化和灵活的框架。它扩展了SMS-WSJ数据库的代码库以生成混合信号,以便能够生成与经典语音混合数据库相对应的会议式语音混合物和混合信号。
会议数据描述了一个高度动态的设置。两种具有MMS-MSG的环境,我们都不旨在提供一个新的数据库。
取而代之的是,我们希望提供一个适应性的框架,该框架允许在尽可能多的环境中进行访问和转录系统的原型和评估。
MMS-MSG的核心方面是会议式数据的生成。会议是以模块化的方式生成的。可调参数为:
采样过程是模块化的,因此可以通过稍微更改采样管道来创建许多方案。我们提供示例类,以说明如何使用单个模块。如果不支持方案,则可以轻松实现新的采样模块以适应您的要求。
MMS-MSG的数据模拟过程分为参数采样和实际数据生成。通过此,我们支持按需数据生成。这样,只需要保存源数据和会议参数,从而允许模拟各种会议场景,同时最大程度地减少所需的磁盘空间。但是,如果您的工作流程需要将它们保存到硬盘上,我们还支持会议数据的离线生成。
我们根据当前使用的源分离数据库的规格提供代码来生成语音混合物,其中多个扬声器的单个话语彼此部分或完全重叠。通过使用MMS-MSG生成这些数据库的培训数据,我们提供了动态混合的本地支持。
支持的语音混合数据库:
计划:
混合物发生器使用Lazy_Dataset。虽然可以在没有Lazy_DataSet的情况下使用MMS_MSG的核心功能,但某些功能(例如动态混合和数据库抽象)当时不可用。
from mms_msg . databases . classical . full_overlap import WSJ2Mix
from mms_msg . sampling . utils import collate_fn
db = WSJ2Mix ()
# Get a train dataset with dynamic mixing
# This dataset only emits the metadata of the mixtures, it doesn't load
# the data yet
ds = db . get_dataset ( 'train_si284_rng' )
# The data can be loaded by mapping a database's load_example function
ds = ds . map ( db . load_example )
# Other dataset modifications (see lazy_dataset doc)
ds = ds . shuffle ( reshuffle = True )
ds = ds . batch ( batch_size = 8 ). map ( collate_fn )
# ...
# Parallelize data loading with lazy_dataset
ds = ds . prefetch ( num_workers = 8 , buffer_size = 16 )
# The dataset can now be used in any training loop
for example in ds :
# ... do fancy stuff with the example.
# The loaded audio data is in example['audio_data']
print ( example )
加载示例后,任何其他数据修改程序都可以直接映射到ds
。
可以将lazy_dataset.Dataset
插入torch.utils.data.DataLoader
:
from mms_msg . databases . classical . full_overlap import WSJ2Mix
db = WSJ2Mix ()
ds = db . get_dataset ( 'train_si284_rng' ). map ( db . load_example )
# Parallelize data loading with torch.utils.data.DataLoader
from torch . utils . data import DataLoader
loader = DataLoader ( ds , batch_size = 8 , shuffle = True , num_workers = 8 )
for example in loader :
print ( example )
输入示例应该具有此结构:
example = {
'audio_path' : {
'observation' : 'single_speaker_recording.wav'
},
'speaker_id' : 'A' ,
'num_samples' : 1234 , # Number of samples of the observation file
# 'num_samples': {'observation': 1234} # Alernative, if other audios are present
'dataset' : 'test' , # The input dataset name
'example_id' : 'asdf1234' , # Unique ID of this example. Optional if the input data is passes as a dict
'scenario' : 'cafe-asdf1234' , # (Optional) If provided, mms_msg makes sure that all examples of the same speaker in a mixture share the same scenario
# ... (any additional keys)
}
选择混合物的话语后,这些话语示例被标准化并“整理”,这导致了与此类似的结构:
example = {
'audio_path' : {
'original_source' : [
'source1.wav' ,
'source2.wav' ,
],
},
'speaker_id' : [
'A' , 'B'
],
'num_samples' : { # The structure under some keys mirrors the structure in 'audio_path'
'original_source' : [
1234 , 4321
]
},
'source_id' : [ # Reference to the source examples this mixture was created from
'asdf1234' , 'asdf1235'
],
...
}
从这样的结构开始,可以应用采样模块,以填充示例,例如,例如,例如,偏移或缩放话语。
为mms_msg.databases
中的一些常见场景提供了数据库类或定义。每个数据库类都必须定义两种方法:
get_mixture_dataset
,它封装了“采样”阶段并构建了采样模块的管道,并且load_example
,提供“仿真”阶段,即加载和混合音频数据。基本(无参数)数据库看起来像这样:
from mms_msg . databases . database import MMSMSGDatabase
from lazy_dataset . database import JsonDatabase
import mms_msg
class MyDatabase ( JsonDatabase , MMSMSGDatabase ):
def get_mixture_dataset ( self , name , rng ):
ds = mms_msg . sampling . source_composition . get_composition_dataset (
input_dataset = super (). get_dataset ( name ),
num_speakers = 2 ,
rng = rng ,
)
ds = ds . map ( mms_msg . sampling . pattern . classical . ConstantOffsetSampler ( 8000 ))
ds = ds . map ( mms_msg . sampling . environment . scaling . ConstantScalingSampler ( 0 ))
return ds
def load_example ( self , example ):
return mms_msg . simulation . anechoic . anechoic_scenario_map_fn ( example )
并且可以实例化
db = MyDatabase ( 'path/to/source/database.json' )
下一节将描述数据集采样管道的结构。
这是单个数据集简单采样管道的一个示例:
import mms_msg
input_ds = ... # Get source utterance examples from somewhere
# Compute a composition of base examples. This makes sure that the speaker distribution
# in the mixtures is equal to the speaker distribution in the original database.
ds = mms_msg . sampling . source_composition . get_composition_dataset ( input_dataset = input_ds , num_speakers = 2 )
# If required: Offset the utterances
ds = ds . map ( mms_msg . sampling . pattern . classical . ConstantOffsetSampler ( 0 ))
# If required: Add log_weights to simulate volume differences
ds = ds . map ( mms_msg . sampling . environment . scaling . UniformScalingSampler ( max_weight = 5 ))
采样过程始终始于创建每种混合物的“源组成”,即采样(基本)话语。这是在get_composition_dataset
中完成的,该算法实现了类似于SMS-WSJ的采样算法,该算法经常同样地使用源数据库中的每种话语。
之后,可以应用采样模块来模拟不同的口语模式或环境。上面的示例将所有偏移设置为零(即,所有话语始于混合物的开头),并使用ConstantOffsetSampler
,并带有一个随机刻度,最大为5db,并带有均匀尺寸采样UniformScalingSampler
。
还有许多其他抽样模块,包括模拟会议风格的语言模式的模拟模块。可以在此笔记本中找到示例。
mms_msg
中的混合物是通过将单个采样模块应用于一个接一个的示例来创建的。每个采样模块都是完全确定的,即其输出仅取决于其超参数和输入示例,但不允许维持可变状态。这是为了确保可重复性:采样不取决于产生混合物的顺序,应用模块的数字或顺序。
采样模块是一种可呼叫,可作为词典接收(中间)混合物,对其进行修改并返回。一个基本的采样模块,以无效参数的函数实现,可以看起来像这样:
import mms_msg
def my_sampling_module ( example : dict ) -> dict :
# Get a deterministic random number generator based on the input example
# and an additional seed string. The seed string ensures that the RNGs
# differ between different sampling modules
rng = mms_msg . sampling . utils . rng . get_rng_example ( example , 'my_sampler' )
# Sample whatever based on RNG and possibly the contents of example
example [ 'my_random_number' ] = rng . random ()
return example
一个重要的部分是mms_msg.sampling.utils.rng.get_rng_example
函数。它返回一个np.random.Generator
对象,该对象是用示例字典(示例-ID和数据集)和附加种子字符串的基本信息初始化的种子初始化的。这意味着,每次将模块应用于同一输入示例时,模块中生成的随机数都是相等的。
如果您的采样模块具有超参数,我们建议使用冷冻的数据类别来确保不可变性:
import mms_msg
from dataclasses import dataclass
@ dataclass ( frozen = True )
class MySamplingModule :
size : int = 42
def __call__ ( self , example ):
rng = mms_msg . sampling . utils . rng . get_rng_example ( example , 'my_sampler' )
# Sample whatever based on RNG and possibly the contents of example
example [ 'my_random_number' ] = rng . random ( self . size )
return example
本笔记本中给出了一个更实用的示例。
MMS-MSG在以下出版物中提出:
@inproceedings { cordlandwehr2022mms_msg ,
title = { MMS-MSG: A Multi-purpose Multi-Speaker Mixture Signal Generator } ,
author = { Tobias Cord-Landwehr and Thilo von Neumann and Christoph Boeddeker and Reinhold Haeb-Umbach } ,
year = { 2022 } ,
booktitle = { International Workshop on Acoustic Signal Enhancement (IWAENC) } ,
publisher = { {IEEE} } ,
} ```