赞
踩
场景:
安装:
pip install pyannote.audio
- # _*_ coding: utf-8 _*_
-
- import torch
- from pyannote.audio import Model, Pipeline, Inference
- from pyannote.core import Segment
- from scipy.spatial.distance import cosine
-
-
- def extract_speaker_embedding(pipeline, audio_file, speaker_label):
- diarization = pipeline(audio_file)
- speaker_embedding = None
- for turn, _, label in diarization.itertracks(yield_label=True):
- if label == speaker_label:
- segment = Segment(turn.start, turn.end)
- speaker_embedding = inference.crop(audio_file, segment)
- break
- return speaker_embedding
-
- # 对于给定的音频,提取声纹特征并与人库中的声纹进行比较
- def recognize_speaker(pipeline, audio_file):
- diarization =

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。