From cdf91c75a0708940aad4b434c42c6057af9f4803 Mon Sep 17 00:00:00 2001 From: fdechaumont Date: Mon, 4 Apr 2022 15:55:41 +0200 Subject: [PATCH] now convert also from 300kHz to 300kHz --- LMT/USV2/convert/convertTo300khz.py | 33 +++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/LMT/USV2/convert/convertTo300khz.py b/LMT/USV2/convert/convertTo300khz.py index 33f9c8f..563310d 100644 --- a/LMT/USV2/convert/convertTo300khz.py +++ b/LMT/USV2/convert/convertTo300khz.py @@ -26,25 +26,22 @@ def convert( file ): if frameRate == 300000: - print("File is already in 300kHz: " , file ) - return - - print("Frame rate : " , frameRate ) - if frameRate != 300000: - print("Converting sampling rate to 300kHz...") - - try: - duration = librosa.get_duration(filename=file) - print("Duration: " , duration , " seconds") - y, sr = librosa.load( file , mono=True, sr=300000) - - convertedFile = file+".converted.wav" - sf.write( convertedFile, y, sr, subtype='PCM_16') - print("Converting framerate done") + print("File is already in 300kHz: " , file , "... (converting anyway)") + + print("Converting sampling rate to 300kHz...") + + try: + duration = librosa.get_duration(filename=file) + print("Duration: " , duration , " seconds") + y, sr = librosa.load( file , mono=True, sr=300000) - except: - print("Error in conversion") - return + convertedFile = file+".converted.wav" + sf.write( convertedFile, y, sr, subtype='PCM_16') + print("Converting framerate done") + + except: + print("Error in conversion") + return # end convert