Win10 openSMILE2.3.0
選擇openSMILE處理音頻,只是看到關於speech emtion recognition論文中大多使用該工具,所以起步先嘗試使用該工具。
按照openSMILE-book 中步驟使用VS2010編譯未果,奈何自己cpp學得不咋地,調試摸不到頭腦,希望大神可以給出相應教程。
編譯也不過是編譯出一個友好的UI界面,不編譯也並不影響使用,於是我選擇在cmd下采用命令行的形式執行。單個音頻處理可以參考http://blog.csdn.net/jaster_wisdom/article/details/56849291
然后我使用python調用cmd去進行的批處理,當然,你也可以直接寫一個bat文件。下面這段代碼只是示范,可以根據自己音頻的存儲形式自行調整。
# -*- coding: utf-8 -*- """ Created on Tue Nov 28 22:50:01 2017 @author: jackherrick """ import os from subprocess import call #sunprocess is used for replacing other functions ex. os.system os.popen…… import time #path constants pathExecute = "C:\\Users\\jackherrick\\Desktop\\openSMILE\\opensmile\\opensmile-2.3.0\\" pathExcuteFile = pathExecute + "bin\\Win32\\" + "SMILExtract_Release" pathConfig = pathExecute + "config\\" + "IS09_emotion.conf" pathAudioRoot = "C:\\Users\\jackherrick\\Documents\\MyCode\\liuchanhg\\" pathOutputRoot = "C:\\Users\\jackherrick\\Documents\\MyCode\\testData\\" #the founction of excuting command def excuteCMD(_pathExcuteFile,_pathConfig,_pathAudio,_pathOutput): cmd = _pathExcuteFile + " -C "+ _pathConfig +" -I "+ _pathAudio + " -O " + _pathOutput call(cmd,shell=True) # subprocess.popen(cmd, shell=True) # it's parallel computing, while call is serial computing #the founction of looping OuterLayer(include looping SecondLevel) def loopExcuteOuterLayer(_pathExcuteFile,_pathConfig,_pathAudioRoot,_pathOutputRoot): flag = -1 for rt, dirs, files in os.walk(_pathAudioRoot): if os.path.isdir(rt): if flag == -1: listDirlist = dirs else: _pathOutputRootSecond = os.path.join(_pathOutputRoot,listDirlist[flag]) _pathAudioRootSecond = os.path.join(_pathAudioRoot,listDirlist[flag]) if not os.path.exists(_pathOutputRootSecond): os.mkdir(_pathOutputRootSecond) loopExcuteInnerLayer(_pathExcuteFile,_pathConfig,_pathAudioRootSecond,_pathOutputRootSecond) flag = flag + 1 #the founction of looping InnerLayer def loopExcuteInnerLayer(_pathExcuteFile,_pathConfig,_pathAudioRoot,_pathOutputRoot): for i in os.listdir(_pathAudioRoot): nameBehind = os.path.splitext(i)[1] nameFront = os.path.splitext(i)[0] if nameBehind =='.wav': print(i) _pathOutput = os.path.join(_pathOutputRoot, nameFront+".txt") _pathAudio = os.path.join(_pathAudioRoot, i) excuteCMD(_pathExcuteFile,_pathConfig,_pathAudio,_pathOutput) if __name__ == '__main__': time1 = time.time() loopExcuteOuterLayer(pathExcuteFile, pathConfig, pathAudioRoot, pathOutputRoot) time2 = time.time()A

