def get_praat_pitch(audio_file): """Given a wav file, use Praat to return a dictionary containing pitch (in Hz) at each millisecond.""" pl = PraatLoader(praatpath=path.abspath('Praat.app/Contents/MacOS/Praat')) praat_output = pl.run_script('pitch.praat', audio_file) pitch_data = pl.read_praat_out(praat_output) return pitch_data
def praat_analyze_pitch(audio_file): """Given a wav file, use Praat to return a dictionary containing pitch (in Hz) at each millisecond.""" praatpath = path.abspath('Praat.app/Contents/MacOS/Praat') # locate Praat executable pl = PraatLoader(praatpath=praatpath) # create instance of PraatLoader object praat_output = pl.run_script('pitch.praat', audio_file) # run pitch script in Praat pitch_data = pl.read_praat_out(praat_output) # turn Praat's output into Python dict return pitch_data
def _檢查查甫查某(cls, 檔名): pl = PraatLoader() 音懸結果 = pl.run_script('pitch.praat', 檔名) 查某 = 0 查甫 = 0 # print(檔名, 音懸結果) for 資料 in pl.read_praat_out(音懸結果).values(): 音懸 = 資料['Pitch'] if 音懸 != 0: if 音懸 > cls.查某查甫音懸門檻: 查某 += 1 else: 查甫 += 1 # 一個0.001秒 if 查某 + 查甫 <= 50: return None if 查某 >= 查甫: return '查某' return '查甫'
from praatinterface import PraatLoader pl = PraatLoader(praatpath = '/usr/bin/praat') in_dir = '/home/pi/Documents/Project_Jammin/speech_emotion_classifier/wav/wav/carlos/casa_may_24_2016' #in_dir = '/home/pi/Documents/Project_Jammin/speech_emotion_classifier/test' out_dir = '/home/pi/Documents/Project_Jammin/speech_emotion_classifier/vectors/carlos/casa_may_24_2016/mfcc' #out_dir = '/home/pi/Documents/Project_Jammin/speech_emotion_classifier/vectors/live' text = pl.run_script('/home/pi/Documents/Project_Jammin/speech_emotion_classifier/wav2mfcc.praat', in_dir, out_dir ) #text = pl.run_script('/home/pi/Documents/Project_Jammin/speech_emotion_classifier/formants.praat','/home/pi/Documents/Project_Jammin/speech_recognition/wav/test.wav', 5500, 5) print text mats = pl.read_praat_out(text) print mats print "Done"
# define important directories here trainpath = '/home/ashu/Desktop/emotion/hack-the-talk-exotel/training_dataset' temppath = '/home/ashu/Desktop/emotion/hack-the-talk-exotel/temp' praatpath = '/usr/bin/praat' sound = AudioSegment.from_mp3("one.mp3") print('imported...') # slicing necessary as program gets stuck with long files # we can find out optimal length and then work with it in a loop # lets extend this script to extract features for all files and save them # in some format song = sound[:1000] song.export("one.wav", format="wav") print('exported...') praatpath = '/usr/bin/praat' pl = PraatLoader(praatpath = praatpath, debug = True) text = pl.run_script('formants.praat', '/home/ashu/Desktop/emotion/hack-the-talk-exotel/features/one.wav', 5, 5500) formants = pl.read_praat_out(text) for x in formants: print (x) for y in formants[x]: print (y,':',formants[x][y]) print(type(formants)) # formants is a dictionary so we can append it to create dictionary for whole time interval # this way we have several dictionaries for several features # we can also manipulate these dictionaries to form arrays (lists) for corresponding feature
def test_formants(praatpath, sound_file): pl = PraatLoader(praatpath = praatpath, debug = True) text = pl.run_script('formants.praat',sound_file, 5, 5500) formants = pl.read_praat_out(text)
def test_formants(praatpath, sound_file): pl = PraatLoader(praatpath=praatpath, debug=True) text = pl.run_script('formants.praat', sound_file, 5, 5500) formants = pl.read_praat_out(text)