Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added methods for classifying raw audio buffers #241

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pyAudioAnalysis.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: pyAudioAnalysis
Version: 0.2.5
Summary: Python Audio Analysis Library: Feature Extraction, Classification, Segmentation and Applications
Home-page: https://github.com/tyiannak/pyAudioAnalysis
Author: Theodoros Giannakopoulos
Author-email: [email protected]
License: Apache License, Version 2.0
Description: UNKNOWN
Platform: UNKNOWN
19 changes: 19 additions & 0 deletions pyAudioAnalysis.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
README.md
setup.py
pyAudioAnalysis/__init__.py
pyAudioAnalysis/analyzeMovieSound.py
pyAudioAnalysis/audacityAnnotation2WAVs.py
pyAudioAnalysis/audioAnalysis.py
pyAudioAnalysis/audioAnalysisRecordAlsa.py
pyAudioAnalysis/audioBasicIO.py
pyAudioAnalysis/audioFeatureExtraction.py
pyAudioAnalysis/audioSegmentation.py
pyAudioAnalysis/audioTrainTest.py
pyAudioAnalysis/audioVisualization.py
pyAudioAnalysis/convertToWav.py
pyAudioAnalysis/utilities.py
pyAudioAnalysis.egg-info/PKG-INFO
pyAudioAnalysis.egg-info/SOURCES.txt
pyAudioAnalysis.egg-info/dependency_links.txt
pyAudioAnalysis.egg-info/not-zip-safe
pyAudioAnalysis.egg-info/top_level.txt
1 change: 1 addition & 0 deletions pyAudioAnalysis.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions pyAudioAnalysis.egg-info/not-zip-safe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions pyAudioAnalysis.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyAudioAnalysis
33 changes: 16 additions & 17 deletions pyAudioAnalysis/audioBasicIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ def convertDirMP3ToWav(dirName, Fs, nC, useMp3TagsAsName = False):
'''

types = (dirName+os.sep+'*.mp3',) # the tuple of file types
filesToProcess = []
filesToProcess = []

for files in types:
filesToProcess.extend(glob.glob(files))
filesToProcess.extend(glob.glob(files))

for f in filesToProcess:
#tag.link(f)
audioFile = eyed3.load(f)
if useMp3TagsAsName and audioFile.tag != None:
audioFile = eyed3.load(f)
if useMp3TagsAsName and audioFile.tag != None:
artist = audioFile.tag.artist
title = audioFile.tag.title
if artist!=None and title!=None:
if len(title)>0 and len(artist)>0:
wavFileName = ntpath.split(f)[0] + os.sep + artist.replace(","," ") + " --- " + title.replace(","," ") + ".wav"
else:
wavFileName = f.replace(".mp3",".wav")
wavFileName = f.replace(".mp3",".wav")
else:
wavFileName = f.replace(".mp3",".wav")
wavFileName = f.replace(".mp3",".wav")
else:
wavFileName = f.replace(".mp3",".wav")
wavFileName = f.replace(".mp3",".wav")
command = "avconv -i \"" + f + "\" -ar " +str(Fs) + " -ac " + str(nC) + " \"" + wavFileName + "\"";
print(command)
os.system(command.decode('unicode_escape').encode('ascii','ignore').replace("\0",""))
Expand All @@ -50,15 +50,15 @@ def convertFsDirWavToWav(dirName, Fs, nC):
filesToProcess = []

for files in types:
filesToProcess.extend(glob.glob(files))
filesToProcess.extend(glob.glob(files))

newDir = dirName + os.sep + "Fs" + str(Fs) + "_" + "NC"+str(nC)
if os.path.exists(newDir) and newDir!=".":
shutil.rmtree(newDir)
os.makedirs(newDir)
shutil.rmtree(newDir)
os.makedirs(newDir)

for f in filesToProcess:
_, wavFileName = ntpath.split(f)
for f in filesToProcess:
_, wavFileName = ntpath.split(f)
command = "avconv -i \"" + f + "\" -ar " +str(Fs) + " -ac " + str(nC) + " \"" + newDir + os.sep + wavFileName + "\"";
print(command)
os.system(command)
Expand All @@ -78,16 +78,16 @@ def readAudioFile(path):
strsig = s.readframes(nframes)
x = numpy.fromstring(strsig, numpy.short).byteswap()
Fs = s.getframerate()
elif extension.lower() == '.mp3' or extension.lower() == '.wav' or extension.lower() == '.au' or extension.lower() == '.ogg':
elif extension.lower() == '.mp3' or extension.lower() == '.wav' or extension.lower() == '.au' or extension.lower() == '.ogg':
try:
audiofile = AudioSegment.from_file(path)
#except pydub.exceptions.CouldntDecodeError:
except:
print("Error: file not found or other I/O error. "
"(DECODING FAILED)")
return (-1,-1)
return (-1,-1)

if audiofile.sample_width==2:
if audiofile.sample_width==2:
data = numpy.fromstring(audiofile._data, numpy.int16)
elif audiofile.sample_width==4:
data = numpy.fromstring(audiofile._data, numpy.int32)
Expand All @@ -101,7 +101,7 @@ def readAudioFile(path):
else:
print("Error in readAudioFile(): Unknown file type!")
return (-1,-1)
except IOError:
except IOError:
print("Error: file not found or other I/O error.")
return (-1,-1)

Expand All @@ -128,4 +128,3 @@ def stereo2mono(x):
return ( (x[:,1] / 2) + (x[:,0] / 2) )
else:
return -1

Loading