Comments (6)
cool, I can it. Here's the script:
import constants as c
from pre_process import extract_features
from models import convolutional_model
from utils import get_last_checkpoint_if_any
from scipy.io.wavfile import read
import numpy as np
def clipped_audio(x, num_frames=c.NUM_FRAMES):
if x.shape[0] > num_frames + 20:
bias = np.random.randint(20, x.shape[0] - num_frames)
clipped_x = x[bias: num_frames + bias]
elif x.shape[0] > num_frames:
bias = np.random.randint(0, x.shape[0] - num_frames)
clipped_x = x[bias: num_frames + bias]
else:
clipped_x = x
return clipped_x
if __name__ == '__main__':
model = convolutional_model()
last_checkpoint = get_last_checkpoint_if_any(c.CHECKPOINT_FOLDER)
print(last_checkpoint)
model.load_weights(last_checkpoint)
_, utt1 = read('demo/87-121553-0002.wav')
utt1 = utt1 / (2**15 - 1)
feat1 = extract_features(utt1)
feat1 = clipped_audio(feat1)
feat1 = feat1[np.newaxis, ...]
_, utt2 = read('demo/103-1240-0002.wav')
utt2 = utt2 / (2**15 - 1)
feat2 = extract_features(utt2)
feat2 = clipped_audio(feat2)
feat2 = feat2[np.newaxis, ...]
print(feat1.shape, feat2.shape)
emb1 = model.predict(feat1)
emb2 = model.predict(feat2)
# similarity
mul = np.multiply(emb1, emb2)
s = np.sum(mul, axis=1)
print(s)
from deep_speaker-speaker_recognition_system.
In the inference, you do not need to prepare anchor
...
The general inference process is as follows:
- Prepare data:
Get the audio, and extract MFCC features, just similar the training preprocess. Please view details in functionextract_features
which is located inpre_process.py
- Predict on model :
embedding = model.predict(input)
Then you will get 512-dimensional embedding vector. - Use this embedding vector to verification or classification tasks.
Suppose there are two utterances that need to be verified if they were made by the same person.
We first get the embedding vector for 2 utterances
emb1= model.predict(utt1); emb2= model.predict(utt2)
If the similarity between the two embeddings is greater than a certain threshold (e.g. 0.5), we can determine that the two utterances originated from the same person.
utt1 and utt2 has the same speaker if sim(emb1,emb2)>threshold
from deep_speaker-speaker_recognition_system.
Thanks for your quick response. Much appreciated.
I will try as you suggested. ^^
from deep_speaker-speaker_recognition_system.
I've tried the above code but each time i get a different similarity value. How is this possible?
from deep_speaker-speaker_recognition_system.
I've tried the above code but each time i get a different similarity value. How is this possible?
Hi,
I think the main reason is the random clip in def clipped_autio
in the code. The audio was random clipping before feeding into the model if the audio is too long.
You can modify the def clipped_autio
to a deterministic clip. (clip the deterministic middle frames of the long audio, or clip different parts of the long audio then average the different results).
Or fixed the random seed during running the code, according to reproducible-results-neural-networks-keras.
from deep_speaker-speaker_recognition_system.
That's cool! Thank you very much.
from deep_speaker-speaker_recognition_system.
Related Issues (20)
- 關於VAD 設定問題 HOT 6
- 关于使用TIMIT数据集的问题 HOT 4
- What is stopping condition in train.py HOT 1
- how do I use the trained model? HOT 1
- How to identify the speaker by inferencing on trained model HOT 1
- Will difference utterences of a same speaker get similar embeddings? HOT 3
- 关于验证两段语音是否为同一个人 HOT 5
- 模型训练卡顿 HOT 7
- 关于inference阶段的疑问 HOT 2
- 关于改小网络结构 HOT 11
- Discussion about combine Timit and Voxceleb datasets for Speaker recognition task, 信道问题 HOT 2
- 环境具体要求 HOT 1
- 运行出错 HOT 7
- 预训练出错!麻烦解答一下
- FileNotFoundError: [Errno 2] No such file or directory: 'best_checkpoint' HOT 1
- npy文件没有生成
- Confusion about Speaker Identification Trial HOT 2
- Confused with the similarity results HOT 1
- 融合模型问题 HOT 1
- train.py HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deep_speaker-speaker_recognition_system.