Views
No views yet
SSL_WavLM library installed.1pip install torch
2# You may also need the original WavLM library from Microsoft1from Transformer_WavLM import WavLM_MHFA
2# 1. Load the Model
3model_path = './SSL_WavLM/model_convert.pt'
4print(f"Loading model from: {model_path}...")
5model = WavLM_MHFA(model_path=model_path)
6model.eval() # Set the model to evaluation mode for inference
7print("Model loaded successfully.")
8
9# 2. Prepare Your Audio Data
10# In a real application, you would load a 16kHz audio file here.
11# The input tensor shape should be: [batch_size, number_of_samples]
12batch_size = 4
13audio_samples = 32000 # This represents ~2 seconds of audio at 16kHz
14dummy_audio = torch.randn(batch_size, audio_samples)
15print(f"\nInput audio shape: {dummy_audio.shape}")
16
17# 3. Extract the Speaker Embedding
18speaker_embedding = model(dummy_audio)
19print("\nEmbedding extracted successfully!")
20print(f"Output embedding shape: {speaker_embedding.shape}")1@inproceedings{peng2023attention,
2title={An attention-based backend allowing efficient fine-tuning of transformer models for speaker verification},
3author={Peng, Junyi and Plchot, Old{\v{r}}ich and Stafylakis, Themos and Mo{\v{s}}ner, Ladislav and Burget, Luk{\'a}{\v{s}} and {\v{C}}ernock{\`y}, Jan},
4booktitle={2022 IEEE Spoken Language Technology Workshop (SLT)},
5pages={555--562},
6year={2023},
7organization={IEEE}
8}
9