I'm creating a human authentication system using human speech.
So the system will have one directory which will hold a human speech and it will be compared with the current speech.
after comparison, it should be able to recognise the person. I don't know whether it is possible or not.
Currently, I am able to do the following things :
- Save the audio file from the microphone.
- Speech-to-text conversion.
- Get the audio shape, duration and data-type.
- Make a graph of the audio file.
code:
import speech_recognition as sr
import numpy as np
import matplotlib.pyplot as plt
from scipy.io import wavfile
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
with open("./a_1.wav","wb") as f:
f.write(audio.get_wav_data())
try:
a = r.recognize_google(audio)
print(a)
except LookupError:
print("Could not understand audio")
frequency_sampling, audio_signal = wavfile.read("./a_1.wav")
print('Signal shape:', audio_signal.shape)
print('Signal Datatype:', audio_signal.dtype)
print('Signal duration:', round(audio_signal.shape[0] /
float(frequency_sampling), 2), 'seconds')
audio_signal = audio_signal / np.power(2, 15)
length_signal = len(audio_signal)
half_length = np.ceil((length_signal + 1) / 2.0).astype(np.int)
signal_frequency = np.fft.fft(audio_signal)
signal_frequency = abs(signal_frequency[0:half_length]) / length_signal
signal_frequency **= 2
len_fts = len(signal_frequency)
if length_signal % 2:
signal_frequency[1:len_fts] *= 2
else:
signal_frequency[1:len_fts-1] *= 2
signal_power = 10 * np.log10(signal_frequency)
x_axis = np.arange(0, half_length, 1) * (frequency_sampling / length_signal) / 1000.0
plt.figure()
plt.plot(x_axis, signal_power, color='black')
plt.xlabel('Frequency (kHz)')
plt.ylabel('Signal power (dB)')
plt.show()
plt.plot(time_axis, audio_signal, color='blue')
plt.xlabel('Time (milliseconds)')
plt.ylabel('Amplitude')
plt.title('Input audio signal')
plt.show()
For speech comparison I tried :
import audiodiff
print audiodiff.audio_equal('a_1.wav', 'a_2.wav', ffmpeg_bin=None)
# false
- A_1 and A_2 both had the same audio content. It returns false
- Matplotlib graph for both the audio was different.
can anyone help me human speech authentication?