Changeset f264b17 for python/demos/demo_pitch.py
- Timestamp:
- Jun 22, 2016, 1:00:10 PM (8 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 4b9443c4
- Parents:
- 60fc05b (diff), 6769586 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/demos/demo_pitch.py
r60fc05b rf264b17 2 2 3 3 import sys 4 from aubio import source, pitch , freqtomidi4 from aubio import source, pitch 5 5 6 6 if len(sys.argv) < 2: 7 print "Usage: %s <filename> [samplerate]" % sys.argv[0]7 print("Usage: %s <filename> [samplerate]" % sys.argv[0]) 8 8 sys.exit(1) 9 9 … … 11 11 12 12 downsample = 1 13 samplerate = 44100 / downsample13 samplerate = 44100 // downsample 14 14 if len( sys.argv ) > 2: samplerate = int(sys.argv[2]) 15 15 16 win_s = 4096 / downsample # fft size17 hop_s = 512 / downsample # hop size16 win_s = 4096 // downsample # fft size 17 hop_s = 512 // downsample # hop size 18 18 19 19 s = source(filename, samplerate, hop_s) … … 37 37 confidence = pitch_o.get_confidence() 38 38 #if confidence < 0.8: pitch = 0. 39 #print "%f %f %f" % (total_frames / float(samplerate), pitch, confidence)39 print("%f %f %f" % (total_frames / float(samplerate), pitch, confidence)) 40 40 pitches += [pitch] 41 41 confidences += [confidence] … … 46 46 47 47 #print pitches 48 import os.path 48 49 from numpy import array, ma 49 50 import matplotlib.pyplot as plt … … 64 65 65 66 def array_from_text_file(filename, dtype = 'float'): 66 import os.path67 from numpy import array68 67 filename = os.path.join(os.path.dirname(__file__), filename) 69 68 return array([line.split() for line in open(filename).readlines()], … … 71 70 72 71 ax2 = fig.add_subplot(312, sharex = ax1) 73 import sys, os.path74 72 ground_truth = os.path.splitext(filename)[0] + '.f0.Corrected' 75 73 if os.path.isfile(ground_truth):
Note: See TracChangeset
for help on using the changeset viewer.