From 700973efda0d3b2b28f87dd313a2ce60c87ba8d0 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Wed, 22 Dec 2021 03:51:16 -0500 Subject: [PATCH] [O] Optimize plot --- src/ina_main.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ina_main.py b/src/ina_main.py index a86baf1..57a1508 100644 --- a/src/ina_main.py +++ b/src/ina_main.py @@ -98,6 +98,13 @@ if __name__ == '__main__': if len(args) < 0: exit(0) + results: BatchResults = BatchResults( + [Result([ResultFrame('female', 0.0, 10.48), ResultFrame('male', 10.48, 12.780000000000001)], + '../test.csv')], + 1.7032792568206787, 1.7032792568206787, 1, + [('../test.csv', 0)]) + + result = results.results[0] # inp = args[0] @@ -109,26 +116,29 @@ if __name__ == '__main__': ax: Axes = plt.gca() # Plot audio - plt.plot(_time, audio) + plt.plot(_time, audio, color='white') # Set size - fig.set_size_inches(10, 1) - fig.set_dpi(200) + # fig.set_dpi(400) + fig.set_size_inches(18, 6) # Cutoff frequency so that the plot looks centered cutoff = min(abs(min(audio)), abs(max(audio))) ax.set_ylim([-cutoff, cutoff]) + ax.set_xlim([result.frames[0].start, result.frames[-1].end]) + + # Draw segmentation areas + colors = {'female': '#F5A9B8', 'male': '#5BCEFA', 'default': 'white'} + for r in result.frames: + color = colors[r.gender] if r.gender in colors else colors['default'] + ax.axvspan(r.start, r.end - 0.01, alpha=.5, color=color) # Export plt.axis('off') - plt.savefig('../image.png', bbox_inches='tight', pad_inches=0, transparent=True) + plt.savefig('../image.png', bbox_inches='tight', pad_inches=0, transparent=False) to_wav('../test.mp3', wav_callback) # seg = Segmenter() # print(process(seg, ['../test.mp3'])) - a = ( - [([('female', 0.0, 10.48), ('male', 10.48, 12.780000000000001)], '../test.csv')], - 1.7032792568206787, 1, 1.7032792568206787, - [('../test.csv', 0, 'ok 1.4748258590698242')])