Giter VIP home page Giter VIP logo

sound-cnn's People

Contributors

awjuliani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sound-cnn's Issues

Error

Hello guys, im trying to run this project and i changed the operator / to // since im using python 3. I'm still having errors:

(pythonProject3) C:\Users\User\PycharmProjects\pythonProject3>python C:\Users\User\Desktop\adsp\train.py 240 44100 C:\Users\User\Desktop\audio\ 1000 1
Traceback (most recent call last):
File "C:\Users\User\Desktop\adsp\train.py", line 19, in
classes, trainX, trainYa, valX, valY, testX, testY = util.processAudio(bpm, samplingRate, mypath)
File "C:\Users\User\Desktop\adsp\utilities.py", line 26, in processAudio
audData = np.reshape(audData[1][:, 1][0:samples * ((seconds * samplingRate) // samples)],
ZeroDivisionError: integer division or modulo by zero

We did some similar job about Audio Recognition Using Spectrogram As Input

By using spectrogram, we can simply treat audio recognition as image recognition, so all the technologies used at image recognition can be used at audio recognition as well

This example uses the same samples as speech_commands, that is wave audio files of people saying ten different words('yes', 'no', 'up', 'down', 'left', 'right', 'on', 'off', 'stop', 'go') from Speech Commands dataset

First, transform the original audio files into spectrograms, we use the following python code to do the task:

import numpy as np
from scipy.io import wavfile

X_SIZE = 16000
IMG_SIZE = 128

def spectrogram(filepath):
	framerate, wav_data = wavfile.read(filepath)

	window_length = 512
	window_shift = 121

	if len(wav_data) > X_SIZE:
		wav_data = wav_data[:X_SIZE]

	X = np.zeros(X_SIZE).astype('float32')
	X[:len(wav_data)] += wav_data
	spec = np.zeros((IMG_SIZE, IMG_SIZE)).astype('float32')

	for i in range(IMG_SIZE):
		start = i * window_shift
		end = start + window_length
		sig = np.abs(np.fft.rfft(X[start:end] * np.hanning(window_length)))
		spec[:,i] = (sig[1:IMG_SIZE + 1])[::-1]

	spec = (spec-spec.min())/(spec.max()-spec.min())
	spec = np.log10((spec * 100 + 0.01))
	spec = (spec-spec.min())/(spec.max()-spec.min()) - 0.5

	return spec

For example, the spectrogram for test.wav is:


To reduce the amount of computation, we limit the size of spectrogram to 128ร—128, so the model can be defined as follow:


Run this model, you will get a test accuracy around 93%(while train accuracy is 98%) after 15 epochs

Reference

Github Link

Working on music and non music classification- when i tried to train i encountered the following error, can anyone help me in solving this issue,

student@student-Vostro-3669:~/sound-cnn$ python train.py 240 44100 /home/student/traindata 1000 150
Traceback (most recent call last):
File "train.py", line 20, in
classes,trainX,trainY,valX,valY,testX,testY = util.processAudio(bpm,samplingRate,mypath)
File "/home/student/sound-cnn/utilities.py", line 29, in processAudio
Ys = np.concatenate(labelList)
ValueError: need at least one array to concatenate

TypeError

Hi. First, I tested mono .wav files which resulted in an error.

Now I'm using stereo .wav files which results in another error.

stefan@stefan-quadcore ~/dev/sound-cnn-master $ ./doit.sh 
Traceback (most recent call last):
  File "train.py", line 20, in <module>
    classes,trainX,trainYa,valX,valY,testX,testY = util.processAudio(bpm,samplingRate,mypath)
  File "/home/stefan/dev/sound-cnn-master/utilities.py", line 24, in processAudio
    audData = np.reshape(audData[1][:,1][0:samples*((seconds*samplingRate)/samples)],[samples,(seconds*samplingRate)/samples])
TypeError: slice indices must be integers or None or have an __index__ method
stefan@stefan-quadcore ~/dev/sound-cnn-master $ cat doit.sh 
python3 train.py 240 44100 ../sounds-stereo/ 1000 100

Why does stuff not work in this world?

Cheers

New predictions

How to use use this model to make new predictions using a new audio file ?
i've tried to reload the model.ckpt file but it keeps giving me errors ...

error

python train.py 240 44100 audio/ 1000 150

Traceback (most recent call last):
File "train.py", line 20, in
classes,trainX,trainYa,valX,valY,testX,testY = util.processAudio(bpm,samplingRate,mypath)
File "/home/fuquo/src/sound-cnn/utilities.py", line 22, in processAudio
seconds = audData[1][:,1].shape[0]/samplingRate
IndexError: too many indices for array

provide a sample case

Could you setup a quick demo?
I cannot understand why any input file to be theorized as a new class and i am getting error on train.py:
'ValueError: Cannot feed value of shape (1, 2) for Tensor u'Placeholder_1:0', which has shape '(?, 4)'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.