Download utils.py from LiXinran1/LSDGNN_ICL: direct link, hf CLI and curl.
- Browser
- Download file 463 Bytes
-
https://huggingface.co/LiXinran1/LSDGNN_ICL/resolve/main/utils.py
- Command line
-
hf download hf://LiXinran1/LSDGNN_ICL/utils.py
-
curl -L -o utils.py https://huggingface.co/LiXinran1/LSDGNN_ICL/resolve/main/utils.py
463 Bytes
| import numpy as np | |
| import torch | |
| def person_embed(speaker_ids, person_vec): | |
| ''' | |
| :param speaker_ids: torch.Tensor ( T, B) | |
| :param person_vec: numpy array (num_speakers, 100) | |
| :return: | |
| speaker_vec: torch.Tensor (T, B, D) | |
| ''' | |
| speaker_vec = [] | |
| for t in speaker_ids: | |
| speaker_vec.append([person_vec[int(i)].tolist() if i != -1 else [0] * 100 for i in t]) | |
| speaker_vec = torch.FloatTensor(speaker_vec) | |
| return speaker_vec |