# import Speaker Recognition File
import GmmSpeakerRec as GSR
# import librosa for audio loading
import librosa
# import Ipython for display the audio content
from IPython.display import display, Audio
# Create a new recognizer and enroll training data for male and female voices
Speaker = GSR.GMMRec()
audio_path = './Audio/fdaw0.wav'
y_fdaw0, sr = librosa.load(audio_path, sr = 16000)
Speaker.enroll('fdaw0', y_fdaw0, fs = 16000)
audio_path = './Audio/fdml0.wav'
y_fdml0, sr = librosa.load(audio_path, sr = 16000)
Speaker.enroll('fdml0', y_fdml0, fs = 16000)
# Train the recognition model
Speaker.train()
# Play the training audio
display(Audio(data = y_fdaw0, rate = sr))
# Play the training audio
display(Audio(data = y_fdml0, rate = sr))
# Load the testing audio
audio_path = './Audio/test.wav'
y_test, sr = librosa.load(audio_path, sr = 16000)
# Play the testing audio
display(Audio(data = y_test, rate = sr))
# Run recognition algorithm on the testing audio
Speaker.recognize(y_test, step = 1, duration = 2.5, fs = sr, disp = True)
Recognition results: 0:00:00 fdaw0
0:00:01 fdaw0
0:00:02 fdaw0
0:00:03 fdml0
0:00:04 fdml0
0:00:05 fdml0
0:00:06 fdml0
0:00:07 fdaw0
0:00:08 fdaw0
0:00:09 fdaw0
0:00:10 fdaw0
0:00:11 fdml0