code
stringlengths
17
6.64M
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...
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=100, 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='stfthop100', input_tdim=3200) model = PasstBasicWrapper(mel=me...
def load_model(model_path='', mode='all', **kwds): model = get_2lvl_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_2lvl_model(**kwargs): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=100, 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='stfthop100', input_tdim=3200) model = PasstBasicWrapper(mel=mel...
def load_model(model_path='', mode='all', **kwds): model = get_2lvl_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_2lvl_model(**kwargs): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=100, 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='stfthop100', input_tdim=3200) model = PasstBasicWrapper(mel=mel...
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=160, 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='stfthop160', input_tdim=2000) model = PasstBasicWrapper(mel=me...
def load_model(model_path='', mode='all', **kwds): model = get_2lvl_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_2lvl_model(**kwargs): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=160, 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='stfthop160', input_tdim=2000) model = PasstBasicWrapper(mel=mel...
def load_model(model_path='', mode='all', **kwds): model = get_2lvl_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_2lvl_model(**kwargs): mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=160, 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='stfthop160', input_tdim=2000) model = PasstBasicWrapper(mel=mel...
class AugmentMelSTFT(nn.Module): def __init__(self, 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=1, fmax_aug_range=1000): torch.nn.Module.__init__(self) self.win_length = win_length self.n_mels =...
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...