#!/usr/bin/env python # coding: utf-8 # In[2]: # 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 # In[3]: # 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) # In[4]: # Train the recognition model Speaker.train() # In[5]: # Play the training audio display(Audio(data = y_fdaw0, rate = sr)) # Play the training audio display(Audio(data = y_fdml0, rate = sr)) # In[6]: # 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) # In[ ]: