Skip to content

Commit

Permalink
Minor tweaks to examples. Added .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
constellationsanonymous committed Dec 24, 2018
1 parent 5749f37 commit f2a5bb8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
models/example_model.hdf5
10 changes: 1 addition & 9 deletions example_fileprediction_playback.py
@@ -1,19 +1,14 @@
from vggish_input import waveform_to_examples
import numpy as np
from scipy.io import wavfile
from keras.models import load_model
import vggish_params
import pyaudio
from pathlib import Path
import time
import tensorflow as tf
import socket
import os, sys, inspect
import wave
import argparse
import wget
import ubicoustics
from collections import Counter

# Variables
FORMAT = pyaudio.paInt16
Expand All @@ -22,7 +17,6 @@
CHUNK = RATE
float_dtype = '>f4'


###########################
# Download model, if it doesn't exist
###########################
Expand Down Expand Up @@ -56,7 +50,6 @@
label[k] = context[k]

# Setup Callback
votes = []
def audio_samples(input, frame_count, time_info, status_flags):
global graph
in_data = wf.readframes(frame_count)
Expand All @@ -74,15 +67,14 @@ def audio_samples(input, frame_count, time_info, status_flags):
m = np.argmax(prediction[0])
if (m < len(label)):
p = label[m]
votes.append(p)
print("Prediction: %s (%0.2f)" % (ubicoustics.to_human_labels[label[m]], prediction[0,m]))
n_items = prediction.shape[1]
else:
print("KeyError: %s" % m)

return (in_data, pyaudio.paContinue)

# Start Reading from system's default audio input
# Setup pyaudio waveread stream
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, output=True, frames_per_buffer=CHUNK, stream_callback=audio_samples)

Expand Down
4 changes: 2 additions & 2 deletions example_liveprediction_detail.py
Expand Up @@ -32,7 +32,7 @@ def download_model(url,output):
return wget.download(url,output)

###########################
# Checl Microphone
# Check Microphone
###########################
print("=====")
print("1 / 2: Checking Microphones... ")
Expand Down Expand Up @@ -100,7 +100,7 @@ def download_model(url,output):
##############################
# Setup Audio Callback
##############################
output_lines = []*32
output_lines = []*OUTPUT_LINES
audio_rms = 0
candidate = ("-",0.0)

Expand Down
1 change: 1 addition & 0 deletions helpers.py
@@ -1,3 +1,4 @@
# Helper functions, written by GL 12/2018
import easing
import sys
import time
Expand Down

0 comments on commit f2a5bb8

Please sign in to comment.