-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deployed e6c4a70 with MkDocs version: 1.6.1
- Loading branch information
0 parents
commit ead6d02
Showing
364 changed files
with
199,041 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<mxfile host="www.draw.io" modified="2019-12-05T18:28:28.327Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" etag="4B4RHLqeErGk9YAUnP_C" version="12.3.7" type="device" pages="1"><diagram id="xq_sSW7vf1Avch4HxVfm" name="Page-1">7Vxbc9o4GP01eQxjS/LtkUKSdrbJZJrZ2eapo9gCtDWIFeLWX7/yDVuWSaD4QhPCDKBPsix/5+jo04VcwcF0c8fxfHLPAhJeASPYXMHhFQDXALjyI7JsEwtwnMQw5jRITGZueKK/SGo0UuuSBmShFBSMhYLOVaPPZjPiC8WGOWdrtdiIhepd53hMNMOTj0Pd+g8NxCSxusDJ7Z8JHU+yO5u2l+RMcVY4fZLFBAdsXTDBmys44IyJ5Nt0MyBh5LzML8l1t3tydw3jZCYOueCvz182jwj9etiywXzg4NWPH0/XwEobJ7bZE5NAOiBNMi4mbMxmOLzJrZ84W84CElVryFRe5itjc2k0pfFfIsQ2RRMvBZOmiZiGaa5sMd9+T6+PE89RomdlyeGmmDncpqmFwFz0I1SlwQ/xYkH9zHxLw7z6jEgoyy2kkweOnnKvI80dPJLXhE2JbIQswkmIBV2p1+GUYONdud2lj4zKGoGRdgbHSZmQdgVoo57pAGRCx4OmAS21wgVbcp+kdeS4yi+FRuWmGO0jkLfQBfm2kDdNT4UeQRV6BFvF3r1g3x72tqlib8Euu70coC7Y78FeOiV2/qvuS+MZeYsxEa+W9E7kkwL98Tg7neC8oeJ7jqxMPWe4yu85yFFiW0Q8uciUQljgh9kzDPAGQ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5RsS2OC291/XcUAJRPgDgVO9BGqxEAqjqf2QjeDx8Pb22UPwO8QSfa/gF/T1L/UAGB10O2Ze2GB3U24Xm9wk8RkXfQwHH0XWw5YXVtGey5XlxIvcueGWl9w9PpR1krV+FuH+/6H0+fDLc0IbUam5DKZP4b+YQO+X8agDf/Aw==</diagram></mxfile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<mxfile host="www.draw.io" modified="2019-12-05T16:51:33.783Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" etag="QeljNpgT-1b_vimL3-BH" version="12.3.7" type="device" pages="1"><diagram id="WPLDtqaatGJPYjKMvfv_" name="Page-1">7Vtdc9o4FP01eUzGtvzFI4E0uzNNJ9PszjaPwhagrbG8sgjQX7+yLWHLMh8pNiYtYYagI1mW7j336FqCGzBarB8pTOZPJETRjWWE6xswvrEs3/X5ewZsCsA2rAKYURwWkFkCL/gHEqAh0CUOUao0ZIREDCcqGJA4RgFTMEgpWanNpiRS75rAGdKAlwBGOvoPDtlcTMvySvwPhGdzeWfTHRQ1Cygbi5mkcxiSVQUCDzdgRAlhxafFeoSizHbSLsV1n3bUbgdGUcyOuWAV/MCDvx6HIH5d3j8mj6vR6+DWFqNN2UbOGIXcAKJIKJuTGYlh9FCi95Qs4xBl3Rq8VLb5TEjCQZOD/yLGNsKbcMkIh+ZsEYlaPmK6+SauzwuvWeHOkcXxulo53ohSyiBlw8yrHAgimKY4kPAnHJXdSyLZsrZSLiaczXKnIQWUkiUN0B7rSUJCOkNsTztr624eJogsEJ8Uv46iCDL8po4DCsLOtu1Kn/IPwq3vcLFj9OLiNWbfSqfy0qt0Kf9c+jcrbKrOLi4ybVClhnlncN3YT4689Iwo5mZD9GcZY9UYY/XDGN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iW+WnU3zFmm+rKcUgffp0Eofb9D6/hFNo4Z4JgGqevDEd6+8tv5+16FtCht3mx/HVaIQXlT/zAw/8=</diagram></mxfile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<mxfile host="www.draw.io" modified="2019-12-05T16:52:05.234Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" etag="gupGxY8cYijm6JhvRd67" version="12.3.7" type="device" pages="1"><diagram id="WPLDtqaatGJPYjKMvfv_" name="Page-1">7Vttc9o4EP41zNx9SMfvmI8ptOmH9qYzvZtrPiq2AF2NxckmQH/96dWWbBGgMZj2nHRSa3ctS7uPnhUrM/Knq90DAevlJ5zCbOQ56W7kz0aeF0cx/csEeyEIHE8IFgSlQuTWgi/oO5RCR0o3KIWFYVhinJVobQoTnOcwKQ0ZIARvTbM5zsynrsECtgRfEpC1pX+jtFzKaXnjWv4BosVSPdmNJkKzAspYzqRYghRvNZH/buRPCcaluFrtpjBjvlN+Efe9P6CtBkZgXp5ywzb5jiZ/Ptz7+ePm7cP6YTt9nNyN5WiLcq9mDFPqANnEpFziBc5B9q6WviV4k6eQdevQVm3zEeM1FbpU+A8sy72MJtiUmIqW5SqTWjpisv8q7+eNR9Z4E6rmbKcrZ3vZKkpAynsWVSpIMlAUKFHi9yiru1dACpRWa4sJs1kedKQCGiALWL7gvdiv4kjxD/EK0tHSGwnMQImezQcAicRFZVfd+hkj+mjPkYsmciRk5Jqhq+aNO/YC1x9PfNfxQ7PDAm9IAmUfNQDohTaoWsRhcQZEXAXgZ5Bt5JRaoDEhsV2iEn5Zg4Rpt5QXzPDPaaimOMOE3+unAMZzEUeCv0FNEyUxfJpTzYKAFNHwaLoxBBF0qng+Q1LC3csRbQdK3hB6DYfL5rZe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Px6IIUFpwnmNjlTX2ZM2mOcyhGXPGCIRbcwkSSXZiQLXiUgOy+Uq5QmorH62TFNAIZYb2RYUKnMXjJIKcEs1JVcaw5JWSsUlkG7OUi1c1e6yGsASFZptY5mk6yTY0NTUdZp5IvtAE0YcabFdZ0obkCpF1rqVCGOJhJGjmDh7yx9dM5ncfUTABS1EogZoCr8NozkZmrukgJbiMl2N5RciwpwbvcluPwuVDXKWFIBkMyGJLBkAyGZCBrNo1qrqWuc+1kYPsKyU9R2HGdcys7/A5GNKrSE3Zc6glOPpYVtZbeSj1qoFrUP+CibEX+2If1Yi2+zjxHOxb923tDPG4eFsbtio/tA3l8/oIbSebTjmJqzvPf/Qc=</diagram></mxfile> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
import argparse | ||
import sys | ||
import pyaudio | ||
import numpy as np | ||
import audioop | ||
import wave | ||
import tensorflow as tf | ||
import time | ||
|
||
FLAGS = None | ||
IN_FILE = 'in.wav' # name of input file | ||
CHUNK = 4096 # number of data points to read at a time | ||
RATE = 16000 # time resolution of the recording device (Hz) | ||
CHANNELS = 1 # number of channels | ||
|
||
FORMAT = pyaudio.paInt16 # audio format from pyaudio | ||
p=pyaudio.PyAudio() # start the PyAudio class | ||
devinfo = p.get_device_info_by_index(0) # get the first recorder device | ||
|
||
# stream from pyaudio | ||
stream=p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, | ||
frames_per_buffer=CHUNK) | ||
|
||
|
||
def load_graph(filename): | ||
"""Unpersists graph from file as default graph.""" | ||
with tf.io.gfile.GFile(filename, 'rb') as f: | ||
graph_def = tf.compat.v1.GraphDef() | ||
graph_def.ParseFromString(f.read()) | ||
tf.import_graph_def(graph_def, name='') | ||
|
||
|
||
def load_labels(filename): | ||
"""Read in labels, one label per line.""" | ||
return [line.rstrip() for line in tf.io.gfile.GFile(filename)] | ||
|
||
|
||
def run_graph(wav_data, labels, input_layer_name, output_layer_name, | ||
num_top_predictions): | ||
"""Runs the audio data through the graph and prints predictions.""" | ||
with tf.compat.v1.Session() as sess: | ||
# Feed the audio data as input to the graph. | ||
# predictions will contain a two-dimensional array, where one | ||
# dimension represents the input image count, and the other has | ||
# predictions per class | ||
softmax_tensor = sess.graph.get_tensor_by_name(output_layer_name) | ||
predictions, = sess.run(softmax_tensor, {input_layer_name: wav_data}) | ||
|
||
# Sort to show labels in order of confidence | ||
top_k = predictions.argsort()[-num_top_predictions:][::-1] | ||
for node_id in top_k: | ||
human_string = labels[node_id] | ||
score = predictions[node_id] | ||
print('%s (score = %.5f)' % (human_string, score)) | ||
|
||
return 0 | ||
|
||
|
||
def label_wav(wav, labels, graph, input_name, output_name, how_many_labels): | ||
"""Loads the model and labels, and runs the inference to print predictions.""" | ||
if not wav or not tf.io.gfile.exists(wav): | ||
tf.compat.v1.logging.fatal('Audio file does not exist %s', wav) | ||
|
||
if not labels or not tf.io.gfile.exists(labels): | ||
tf.compat.v1.logging.fatal('Labels file does not exist %s', labels) | ||
|
||
if not graph or not tf.io.gfile.exists(graph): | ||
tf.compat.v1.logging.fatal('Graph file does not exist %s', graph) | ||
|
||
labels_list = load_labels(labels) | ||
|
||
# load graph, which is stored in the default session | ||
load_graph(graph) | ||
|
||
with open(wav, 'rb') as wav_file: | ||
wav_data = wav_file.read() | ||
|
||
run_graph(wav_data, labels_list, input_name, output_name, how_many_labels) | ||
|
||
|
||
def prepare(graph, labels): | ||
"""Loads data labels and tensor graphs""" | ||
labels_list = load_labels(labels) | ||
load_graph(graph) | ||
return labels_list | ||
|
||
def main(_): | ||
|
||
# initialize variables and prepare graph | ||
labels = prepare(FLAGS.graph, FLAGS.labels) | ||
recording = False | ||
frames = [] | ||
time_from_previous = 0 | ||
|
||
with tf.compat.v1.Session() as sess: | ||
|
||
# loads softmax tensor | ||
softmax_tensor = sess.graph.get_tensor_by_name(FLAGS.output_name) | ||
|
||
while True: | ||
# transform data into a numpy array | ||
data = np.fromstring(stream.read(CHUNK), dtype=np.int16) | ||
|
||
# get audio rms | ||
rms = audioop.rms(data, 2) | ||
|
||
# if audio rms reaches 900 or more set recording for true | ||
# and start appending the data into the frames array. | ||
|
||
# this means someone is talking | ||
if rms > 900: | ||
if recording == False: | ||
recording = True | ||
frames.append(data) | ||
else: | ||
if recording == True: | ||
time_from_previous = time.time() | ||
|
||
# get data from stream for the next 0.5 seconds | ||
# after the volume | ||
while time.time() - time_from_previous < 0.5: | ||
data = np.fromstring(stream.read(CHUNK),dtype=np.int16) | ||
frames.append(data) | ||
|
||
# write frames inside wav file | ||
_file = wave.open("out.wav","wb") | ||
_file.setnchannels(CHANNELS) | ||
_file.setsampwidth(p.get_sample_size(FORMAT)) | ||
_file.setframerate(RATE) | ||
_file.writeframes(b''.join(frames)) | ||
_file.close() | ||
|
||
# clear frames array since the data was | ||
# written inside wav file | ||
frames = [] | ||
|
||
# read wav file to get the input data for | ||
# our neural network | ||
with open('out.wav', 'rb') as wav_file: | ||
wav_data = wav_file.read() | ||
|
||
# this is where the model predicts based on the input data | ||
predictions, = sess.run(softmax_tensor, {FLAGS.input_name: wav_data}) | ||
|
||
# Sort to show labels in order of confidence | ||
top_k = predictions.argsort()[-FLAGS.how_many_labels:][::-1] | ||
for node_id in top_k: | ||
human_string = labels[node_id] | ||
score = predictions[node_id] | ||
print('%s (score = %.5f)' % (human_string, score)) | ||
recording = False | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'--wav', type=str, default='', help='Audio file to be identified.') | ||
parser.add_argument( | ||
'--graph', type=str, default='', help='Model to use for identification.') | ||
parser.add_argument( | ||
'--labels', type=str, default='', help='Path to file containing labels.') | ||
parser.add_argument( | ||
'--input_name', | ||
type=str, | ||
default='wav_data:0', | ||
help='Name of WAVE data input node in model.') | ||
parser.add_argument( | ||
'--output_name', | ||
type=str, | ||
default='labels_softmax:0', | ||
help='Name of node outputting a prediction in the model.') | ||
parser.add_argument( | ||
'--how_many_labels', | ||
type=int, | ||
default=1, | ||
help='Number of results to show.') | ||
|
||
FLAGS, unparsed = parser.parse_known_args() | ||
tf.compat.v1.app.run(main=main, argv=[sys.argv[0]] + unparsed) |
Binary file not shown.
Oops, something went wrong.