code
stringlengths
17
6.64M
@dataclass class MAE_AST_Pretraining_Config(): data: str = field(default=MISSING, metadata={'help': 'path to data directory'}) sample_rate: int = field(default=16000, metadata={'help': 'target sample rate. audio files will be up/down sampled to this rate'}) normalize: bool = field(default=False, metadata=...
class MAE_AST_Pretraining_Task(): cfg: MAE_AST_Pretraining_Config def __init__(self, cfg: MAE_AST_Pretraining_Config) -> None: super().__init__(cfg) logger.info(f'current directory is {os.getcwd()}') logger.info(f'MAEPretrainingTask Config {cfg}') self.cfg = cfg @property...
class UpstreamExpert(UpstreamBase): '\n The Mockingjay wrapper\n ' def __init__(self, ckpt, options_config=None, **kwargs): super().__init__(**kwargs) if (options_config is not None): print('[UpstreamExpert] - Using upstream expert config file from:', options_config) ...
def mockingjay_local(ckpt, options_config=None, *args, **kwargs): '\n The model from local ckpt\n ckpt (str): PATH\n feature_selection (int): -1 (default, the last layer) or an int in range(0, max_layer_num)\n ' assert os.path.isfile(ckpt) if (options_config is not None): asser...
def mockingjay_url(ckpt, refresh=False, *args, **kwargs): '\n The model from URL\n ckpt (str): URL\n ' return mockingjay_local(_urls_to_filepaths(ckpt, refresh=refresh), *args, **kwargs)
def mockingjay(refresh=False, *args, **kwargs): '\n The default model\n refresh (bool): whether to download ckpt/config again if existed\n ' return mockingjay_origin(*args, refresh=refresh, **kwargs)
def mockingjay_origin(refresh=False, *args, **kwargs): '\n The mockingjay large model on 360hr, with Lel as input and Linear as target\n refresh (bool): whether to download ckpt/config again if existed\n ' return mockingjay_logMelLinearLarge_T_AdamW_b32_500k_360hr_drop1(*args, refresh=refresh, **...
def mockingjay_100hr(refresh=False, *args, **kwargs): '\n The mockingjay base model on 100hr\n refresh (bool): whether to download ckpt/config again if existed\n ' return mockingjay_logMelBase_T_AdamW_b32_200k_100hr(*args, refresh=refresh, **kwargs)
def mockingjay_960hr(refresh=False, *args, **kwargs): '\n The mockingjay base model on 960hr\n refresh (bool): whether to download ckpt/config again if existed\n ' return mockingjay_logMelBase_T_AdamW_b32_1m_960hr_drop1(*args, refresh=refresh, **kwargs)
def mockingjay_logMelBase_T_AdamW_b32_200k_100hr(refresh=False, *args, **kwargs): '\n Feature: 80-dim log Mel\n Alteration: time\n Optimizer: AdamW\n Batch size: 32\n Total steps: 200k\n Unlabled Speech: 100hr\n ' kwargs['ckpt'] = 'https://www.dropbox.com/s/luorglf8mdg67l2/states-200000.c...
def mockingjay_logMelLinearLarge_T_AdamW_b32_500k_360hr_drop1(refresh=False, *args, **kwargs): '\n Feature: 80-dim log Mel (input) / 201-dim Linear (target)\n Alteration: time\n Optimizer: AdamW\n Batch size: 32\n Total steps: 500k\n Unlabled Speech: 360hr\n ' kwargs['ckpt'] = 'https://hu...
def mockingjay_logMelBase_T_AdamW_b32_1m_960hr(refresh=False, *args, **kwargs): '\n Feature: 80-dim log Mel\n Alteration: time\n Optimizer: AdamW\n Batch size: 32\n Total steps: 1M\n Unlabled Speech: 960hr\n ' kwargs['ckpt'] = 'https://www.dropbox.com/s/jzx0xggk663jev6/states-1000000.ckpt...
def mockingjay_logMelBase_T_AdamW_b32_1m_960hr_drop1(refresh=False, *args, **kwargs): '\n Feature: 80-dim log Mel\n Alteration: time\n Optimizer: AdamW\n Batch size: 32\n Total steps: 1M\n Unlabled Speech: 960hr\n Differences: Dropout of 0.1 (instead of 0.3)\n ' kwargs['ckpt'] = 'https...
def mockingjay_logMelBase_T_AdamW_b32_1m_960hr_seq3k(refresh=False, *args, **kwargs): '\n Feature: 80-dim log Mel\n Alteration: time\n Optimizer: AdamW\n Batch size: 32\n Total steps: 1M\n Unlabled Speech: 960hr\n Differences: sequence length of 3k (instead of 1.5k)\n ' kwargs['ckpt'] ...
class TransformerConfig(object): 'Configuration class to store the configuration of a `TransformerModel`.' def __init__(self, config): self.hidden_size = int(config['hidden_size']) self.num_hidden_layers = int(config['num_hidden_layers']) self.num_attention_heads = int(config['num_att...
def prune_linear_layer(layer, index, dim=0): 'Prune a linear layer (a model parameters) to keep only entries in index.\n Return the pruned layer as a new layer with requires_grad=True.\n Used to remove heads.\n ' index = index.to(layer.weight.device) W = layer.weight.index_select(dim, index).clon...
def gelu(x): "Implementation of the gelu activation function.\n For information: OpenAI GPT's gelu is slightly different (and gives slightly different results):\n 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3))))\n Also see https://arxiv.org/abs/1606.08415\n " r...
def swish(x): return (x * torch.sigmoid(x))
class TransformerLayerNorm(nn.Module): def __init__(self, hidden_size, eps=1e-12): 'Construct a layernorm module in the TF style (epsilon inside the square root).' super(TransformerLayerNorm, self).__init__() self.weight = nn.Parameter(torch.ones(hidden_size)) self.bias = nn.Param...
class TransformerInputRepresentations(nn.Module): 'Construct the input representation from spectrogram, and position encodings.' def __init__(self, config, input_dim): super(TransformerInputRepresentations, self).__init__() self.hidden_size = config.hidden_size self.spec_transform = n...
class TransformerSelfAttention(nn.Module): def __init__(self, config, output_attentions=False, keep_multihead_output=False): super(TransformerSelfAttention, self).__init__() if ((config.hidden_size % config.num_attention_heads) != 0): raise ValueError(('The hidden size (%d) is not a m...
class TransformerSelfOutput(nn.Module): def __init__(self, config): super(TransformerSelfOutput, self).__init__() self.pre_layer_norm = config.pre_layer_norm self.dense = nn.Linear(config.hidden_size, config.hidden_size) self.dropout = nn.Dropout(config.hidden_dropout_prob) ...
class TransformerAttention(nn.Module): def __init__(self, config, output_attentions=False, keep_multihead_output=False): super(TransformerAttention, self).__init__() self.output_attentions = output_attentions self.pre_layer_norm = config.pre_layer_norm self.self = TransformerSelfA...
class TransformerIntermediate(nn.Module): def __init__(self, config): super(TransformerIntermediate, self).__init__() self.dense = nn.Linear(config.hidden_size, config.intermediate_size) if isinstance(config.hidden_act, str): self.intermediate_act_fn = ACT2FN[config.hidden_act...
class TransformerOutput(nn.Module): def __init__(self, config): super(TransformerOutput, self).__init__() self.pre_layer_norm = config.pre_layer_norm self.dense = nn.Linear(config.intermediate_size, config.hidden_size) self.dropout = nn.Dropout(config.hidden_dropout_prob) ...
class TransformerLayer(nn.Module): def __init__(self, config, output_attentions=False, keep_multihead_output=False): super(TransformerLayer, self).__init__() self.output_attentions = output_attentions self.pre_layer_norm = config.pre_layer_norm self.attention = TransformerAttentio...
class TransformerEncoder(nn.Module): def __init__(self, config, output_attentions=False, keep_multihead_output=False): super(TransformerEncoder, self).__init__() self.output_attentions = output_attentions self.pre_layer_norm = config.pre_layer_norm layer = TransformerLayer(config,...
class TransformerSpecPredictionHead(nn.Module): def __init__(self, config, output_dim, input_dim=None): super(TransformerSpecPredictionHead, self).__init__() self.output_dim = output_dim if (input_dim is None): self.dense = nn.Linear(config.hidden_size, config.hidden_size) ...
class TransformerInitModel(nn.Module): 'An abstract class to handle weights initialization.' def __init__(self, config, output_attentions, *inputs, **kwargs): super(TransformerInitModel, self).__init__() self.config = config self.output_attentions = output_attentions def init_Tra...
class TransformerModel(TransformerInitModel): "Transformer model.\n\n Params:\n `config`: a TransformerConfig class instance with the configuration to build a new model\n `intput_dim`: int, input dimension of model\n `output_attentions`: If True, also output attentions weights computed by...
class UpstreamExpert(UpstreamBase): def __init__(self, ckpt: str=None, model_config: str=None, **kwargs): '\n Args:\n ckpt:\n The checkpoint path for loading your pretrained weights.\n Can be assigned by the -k option in run_downstream.py\n\n mod...
def mos_wav2vec2_local(ckpt, *args, **kwargs): '\n The model from local ckpt\n ckpt (str): PATH\n ' assert os.path.isfile(ckpt) kwargs['upstream'] = 'wav2vec2' return _UpstreamExpert(ckpt, *args, **kwargs)
def mos_wav2vec2_url(ckpt, refresh=False, *args, **kwargs): '\n The model from URL\n ckpt (str): URL\n ' return mos_wav2vec2_local(_urls_to_filepaths(ckpt), *args, **kwargs)
def mos_wav2vec2(refresh=False, *args, **kwargs): '\n The model from local ckpt\n ckpt (str): PATH\n ' kwargs['ckpt'] = 'https://www.dropbox.com/s/s9zpouk5svu1a4l/wav2vec2-dev-SRCC-best.ckpt?dl=1' return mos_wav2vec2_url(*args, refresh=refresh, **kwargs)
def mos_tera_local(ckpt, *args, **kwargs): '\n The model from local ckpt\n ckpt (str): PATH\n ' assert os.path.isfile(ckpt) kwargs['upstream'] = 'tera' return _UpstreamExpert(ckpt, *args, **kwargs)
def mos_tera_url(ckpt, refresh=False, *args, **kwargs): '\n The model from URL\n ckpt (str): URL\n ' return mos_tera_local(_urls_to_filepaths(ckpt), *args, **kwargs)
def mos_tera(refresh=False, *args, **kwargs): '\n The model from local ckpt\n ckpt (str): PATH\n ' kwargs['ckpt'] = 'https://www.dropbox.com/s/w4jk5bujaoosk69/tera-dev-SRCC-best.ckpt?dl=1' return mos_tera_url(*args, refresh=refresh, **kwargs)
def mos_apc_local(ckpt, *args, **kwargs): '\n The model from local ckpt\n ckpt (str): PATH\n ' assert os.path.isfile(ckpt) kwargs['upstream'] = 'apc' return _UpstreamExpert(ckpt, *args, **kwargs)
def mos_apc_url(ckpt, refresh=False, *args, **kwargs): '\n The model from URL\n ckpt (str): URL\n ' return mos_apc_local(_urls_to_filepaths(ckpt), *args, **kwargs)
def mos_apc(refresh=False, *args, **kwargs): '\n The model from local ckpt\n ckpt (str): PATH\n ' kwargs['ckpt'] = 'https://www.dropbox.com/s/ulng31as15hsvz1/apc-dev-SRCC-best.ckpt?dl=1' return mos_apc_url(*args, refresh=refresh, **kwargs)
class MosDownstream(nn.Module): def __init__(self, upstream_dim, projector_dim, clipping, attention_pooling): super(MosDownstream, self).__init__() self.connector = nn.Linear(upstream_dim, projector_dim) self.model = MosDownstreamModule(input_dim=projector_dim, clipping=clipping, attentio...
class MosDownstreamModule(nn.Module): def __init__(self, input_dim, clipping=False, attention_pooling=False, num_judges=5000, **kwargs): super(MosDownstreamModule, self).__init__() self.mean_net_linear = nn.Linear(input_dim, 1) self.mean_net_clipping = clipping self.mean_net_pooli...
class SelfAttentionPooling(nn.Module): '\n Implementation of SelfAttentionPooling\n Original Paper: Self-Attention Encoding and Pooling for Speaker Recognition\n https://arxiv.org/pdf/2008.01077v1.pdf\n ' def __init__(self, input_dim): super(SelfAttentionPooling, self).__init__() ...
def unfold_segments(tensor, tgt_duration, sample_rate=16000): seg_lengths = int((tgt_duration * sample_rate)) src_lengths = len(tensor) step = (seg_lengths // 2) tgt_lengths = (seg_lengths if (src_lengths <= seg_lengths) else (((src_lengths // step) + 1) * step)) pad_lengths = (tgt_lengths - src_l...
def load_and_convert_fairseq_ckpt(fairseq_source: str, output_path: str=None): from fairseq.data.dictionary import Dictionary (state, cfg) = load_fairseq_ckpt(fairseq_source) dicts: List[Dictionary] = state['task_state']['dictionaries'] symbols = [dictionary.symbols for dictionary in dicts] output...
def load_converted_model(ckpt: str): ckpt_state = torch.load(ckpt, map_location='cpu') for required_key in ['task_cfg', 'model_cfg', 'model_weight', 'dictionaries_symbols']: if (required_key not in ckpt_state): raise ValueError(f'{ckpt} is not a valid checkpoint since the required key: {re...
def multires_hubert_custom(ckpt: str, refresh: bool=False, **kwargs): if ckpt.startswith('http'): ckpt = _urls_to_filepaths(ckpt, refresh=refresh) assert os.path.isfile(ckpt) return _UpstreamExpert(ckpt=ckpt, **kwargs)
def multires_hubert_local(*args, **kwargs): return multires_hubert_custom(*args, **kwargs)
def multires_hubert_base(refresh=False, **kwargs): '\n The monolingual base model\n refresh (bool): whether to download ckpt/config again if existed\n ' kwargs['ckpt'] = 'https://huggingface.co/s3prl/mr_hubert/resolve/main/mrhubert_mono_base.pt' return multires_hubert_custom(refresh=refresh, ...
def multires_hubert_large(refresh=False, **kwargs): '\n The monolingual base model\n refresh (bool): whether to download ckpt/config again if existed\n ' kwargs['ckpt'] = 'https://huggingface.co/s3prl/mr_hubert/resolve/main/mrhubert_mono_large.pt' return multires_hubert_custom(refresh=refresh...
def multires_hubert_multilingual_base(refresh=False, **kwargs): '\n The multilingual base model\n refresh (bool): whether to download ckpt/config again if existed\n ' kwargs['ckpt'] = 'https://huggingface.co/s3prl/mr_hubert/resolve/main/multi_base.pt' return multires_hubert_custom(refresh=ref...
def multires_hubert_multilingual_large400k(refresh=False, **kwargs): '\n The multilingual large model (400k steps)\n refresh (bool): whether to download ckpt/config again if existed\n ' kwargs['ckpt'] = 'https://huggingface.co/s3prl/mr_hubert/resolve/main/multi_large_400k.pt' return multires_...
def multires_hubert_multilingual_large600k(refresh=False, **kwargs): '\n The multilingual large model (600k steps)\n refresh (bool): whether to download ckpt/config again if existed\n ' kwargs['ckpt'] = 'https://huggingface.co/s3prl/mr_hubert/resolve/main/multi_large_600k.pt' return multires_...
class CMVN(nn.Module): __constants__ = ['mode', 'dim', 'eps'] def __init__(self, mode='global', dim=2, eps=1e-10): super(CMVN, self).__init__() if (mode != 'global'): raise NotImplementedError('Only support global mean variance normalization.') self.mode = mode sel...
class FeatureExtractor(nn.Module): 'Feature extractor, transforming file path to Mel spectrogram' def __init__(self, mode='fbank', num_mel_bins=80, decode_wav=False, apply_cmvn=True, **kwargs): super(FeatureExtractor, self).__init__() assert (mode == 'fbank'), 'Only Mel-spectrogram implemente...
def create_transform(audio_config): feat_type = audio_config.pop('feat_type') feat_dim = audio_config.pop('feat_dim') decode_wav = audio_config.pop('decode_wav', False) apply_cmvn = audio_config.pop('cmvn', True) transforms = FeatureExtractor(feat_type, feat_dim, decode_wav, apply_cmvn, **audio_co...
class UpstreamExpert(UpstreamBase): def __init__(self, ckpt, **kwargs): super().__init__(**kwargs) ckpt = torch.load(ckpt, map_location='cpu') config = ckpt['config'] (self.preprocessor, feat_dim) = create_transform(config['data']['audio']) self.model = NPC(feat_dim, **con...
def npc_local(ckpt, *args, **kwargs): '\n The model from local ckpt\n ckpt (str): PATH\n ' assert os.path.isfile(ckpt) return _UpstreamExpert(ckpt, *args, **kwargs)
def npc_url(ckpt, refresh=False, *args, **kwargs): '\n The model from URL\n ckpt (str): URL\n ' return npc_local(_urls_to_filepaths(ckpt, refresh=refresh), *args, **kwargs)
def npc(refresh=False, *args, **kwargs): '\n The default model\n refresh (bool): whether to download ckpt/config again if existed\n ' return npc_360hr(*args, refresh=refresh, **kwargs)
def npc_360hr(refresh=False, *args, **kwargs): '\n The npc standard model on 360hr\n refresh (bool): whether to download ckpt/config again if existed\n ' kwargs['ckpt'] = 'https://huggingface.co/leo19941227/apc_series/resolve/main/npc_360hr.ckpt' return npc_url(*args, refresh=refresh, **kwarg...
def npc_960hr(refresh=False, *args, **kwargs): '\n The npc standard model on 960hr\n refresh (bool): whether to download ckpt/config again if existed\n ' kwargs['ckpt'] = 'https://huggingface.co/leo19941227/apc_series/resolve/main/npc_960hr.ckpt' return npc_url(*args, refresh=refresh, **kwarg...
class VQLayer(nn.Module): def __init__(self, input_size, codebook_size, code_dim, gumbel_temperature): '\n Defines a VQ layer that follows an RNN layer.\n input_size: an int indicating the pre-quantized input feature size,\n usually the hidden size of RNN.\n codebook_size:...
class UpstreamExpert(UpstreamBase): def __init__(self, ckpt, model_config, **kwargs): super().__init__(**kwargs) try: from pase.models.frontend import wf_builder except ModuleNotFoundError: logger.error('Please check https://github.com/s3prl/s3prl/blob/master/s3prl...
class UpstreamExpert(nn.Module): def __init__(self, name: str, refresh=False, window_secs: float=0.16, stride_secs: float=0.05): super().__init__() self.resampler = torchaudio.transforms.Resample(16000, 32000) self.module = importlib.import_module(f'.hear21passt.{name}', __package__) ...
def embeding_size(hop=50, embeding_size=1000): embedings = ((20 * 60) * (1000 / hop)) return (((embedings * embeding_size) * 4) / ((1024 * 1024) * 1024))
def load_model(model_path=''): model = get_concat_2levelmel_model() if torch.cuda.is_available(): model.cuda() return model
def get_scene_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n ' mod...
def get_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding...
def get_basic_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_emb...
def get_basic_model(): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=320, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000) net = get_model_passt(arch='passt_s_swa_p16_128_ap476') model = PasstBasicWrapper(mel=mel, net=net...
def get_concat_2level_model(): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=320, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000) net = get_model_passt(arch='passt_s_swa_p16_128_ap476') model = PasstBasicWrapper(mel=mel,...
def get_2lvl_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embe...
def get_concat_2levelmel_model(): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=320, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000) net = get_model_passt(arch='passt_s_swa_p16_128_ap476') model = PasstBasicWrapper(mel=m...
def get_2lvlmel_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_e...
def load_model(model_path='', mode='all', **kwds): model = get_basic_model(mode=mode, **kwds) return model
def get_scene_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n ' ret...
def get_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding...
def get_basic_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_emb...
def get_basic_model(**kwargs): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=320, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000) net = get_model_passt(arch='passt_s_swa_p16_128_ap476') model = PasstBasicWrapper(mel=mel,...
def load_model(model_path='', mode='all', scene_hop=5000, **kwds): '\n scene_hop: The hop size for the ovelaping windows\n in case the scene audio lenght is larger than 20 seconds.\n Returns:\n model: wrapped PaSST model that can take up to 20 seconds\n of audio without averaging the embeddings.\n...
def get_scene_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n ' ret...
def get_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding...
def get_basic_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_emb...
def get_basic_model(**kwargs): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=320, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000) net = get_model_passt(arch='passt_20sec', input_tdim=2000) model = PasstBasicWrapper(mel=m...
def load_model(model_path='', mode='all', **kwds): model = get_concat_2level_model(mode=mode, **kwds) return model
def get_scene_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n ' ret...
def get_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding...
def get_concat_2level_model(**kwargs): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=320, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000) net = get_model_passt(arch='passt_s_swa_p16_128_ap476') model = PasstBasicWrapper(...
def get_2lvl_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embe...
def load_model(model_path='', mode='all', **kwds): model = get_concat_2levelmel_model(mode=mode, **kwds) return model
def get_scene_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n ' ret...
def get_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding...
def get_concat_2levelmel_model(**kwargs): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=320, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000) net = get_model_passt(arch='passt_s_swa_p16_128_ap476') model = PasstBasicWrapp...
def get_2lvlmel_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_e...
def load_model(model_path='', mode='all', scene_hop=10000, **kwds): '\n scene_hop: The hop size for the ovelaping windows\n in case the scene audio lenght is larger than 30 seconds.\n Returns:\n model: wrapped PaSST model that can take up to 30 seconds\n of audio without averaging the embeddings.\...
def get_scene_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n ' ret...
def get_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding...
def get_basic_timestamp_embeddings(audio, model): '\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_emb...
def get_basic_model(**kwargs): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=320, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000) net = get_model_passt(arch='passt_30sec', input_tdim=3000) model = PasstBasicWrapper(mel=m...