# 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
Gender = GSR.GMMRec()
audio_path = './Audio/male.wav'
y_male, sr = librosa.load(audio_path, sr = 44100)
Gender.enroll('Male', y_male)
audio_path = './Audio/female.wav'
y_female, sr = librosa.load(audio_path, sr = 44100)
Gender.enroll('Female', y_female)
# Train the recognition model
Gender.train()
# Save the model to a local file
Gender.dump('gender.model')
# Load the testing audio
audio_path = './Audio/female-male.wav'
y_test, sr = librosa.load(audio_path, sr = 44100)
# Play the testing audio
display(Audio(data = y_test, rate = sr))
# Run recognition algorithm on the testing audio
Gender.recognize(y_test, step = 5, duration = 5, disp = False)