3 Star 0 Fork 1

mirrors_resemble-ai/Resemblyzer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
demo03_projection.py 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
from resemblyzer import preprocess_wav, VoiceEncoder
from demo_utils import *
from itertools import groupby
from pathlib import Path
from tqdm import tqdm
import numpy as np
# DEMO 03: we'll show one way to visualize these utterance embeddings. Since they are
# 256-dimensional, it is much simpler for us to get an overview of their manifold if we reduce
# their dimensionality first. By doing so, we can observe clusters that form for utterances of
# identical characteristics. What we'll see is that clusters form for distinct speakers,
# and they are very tight and even linearly separable.
## Gather the wavs
wav_fpaths = list(Path("audio_data", "librispeech_test-other").glob("**/*.flac"))
speakers = list(map(lambda wav_fpath: wav_fpath.parent.stem, wav_fpaths))
wavs = np.array(list(map(preprocess_wav, tqdm(wav_fpaths, "Preprocessing wavs", len(wav_fpaths)))), dtype=object)
speaker_wavs = {speaker: wavs[list(indices)] for speaker, indices in
groupby(range(len(wavs)), lambda i: speakers[i])}
## Compute the embeddings
encoder = VoiceEncoder()
utterance_embeds = np.array(list(map(encoder.embed_utterance, wavs)))
## Project the embeddings in 2D space
plot_projections(utterance_embeds, speakers, title="Embedding projections")
plt.show()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_resemble-ai/Resemblyzer.git
git@gitee.com:mirrors_resemble-ai/Resemblyzer.git
mirrors_resemble-ai
Resemblyzer
Resemblyzer
master

搜索帮助