From bc5f6c854bf013c108b0308762b6232617d06496 Mon Sep 17 00:00:00 2001 From: HaujetZhao <1292756898@qq.com> Date: Fri, 14 Aug 2020 17:12:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=89=AA=E8=BE=91=E9=83=A8?= =?UTF-8?q?=E5=88=86=EF=BC=8C=E5=9C=A8=E8=BE=93=E5=87=BA=E9=9F=B3=E9=A2=91?= =?UTF-8?q?=E7=89=87=E6=AE=B5=E5=A4=84=EF=BC=8C=E4=B8=8D=E5=86=8D=E6=98=AF?= =?UTF-8?q?=E6=AF=8F=E4=B8=80=E4=B8=AA=20chunk=20=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E9=9F=B3=E9=A2=91=E6=96=87=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E9=82=A3=E6=A0=B7=E6=9C=80=E5=90=8E=E5=90=88=E5=B9=B6=E6=9C=89?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=87=BA=E7=8E=B0=E9=9F=B3=E7=94=BB=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E3=80=82=E7=8E=B0=E5=9C=A8=E6=98=AF=E6=AF=8F?= =?UTF-8?q?=E5=8D=81=E5=88=86=E9=92=9F=E8=BE=93=E5=87=BA=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=20wav=20=E6=96=87=E4=BB=B6=E7=89=87=E6=AE=B5=EF=BC=8C=E6=AF=8F?= =?UTF-8?q?=E4=B8=AA=E7=89=87=E6=AE=B5=E6=9C=80=E5=A4=A7=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=20403.7MB=20=E5=86=85=E5=AD=98=EF=BC=8C=E4=B8=8D=E8=87=B3?= =?UTF-8?q?=E4=BA=8E=E6=8C=A4=E7=88=86=E5=86=85=E5=AD=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QuickCut.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/QuickCut.py b/QuickCut.py index 11517ee..a606135 100644 --- a/QuickCut.py +++ b/QuickCut.py @@ -5532,10 +5532,14 @@ def run(self): lastExistingFrame = None i = 0 concat = open(self.TEMP_FOLDER + "/concat.txt", "a") + outputAudioData = np.zeros((0, audioData.shape[1])) + print('len of chunks: %s' % len(chunks)) + chunksNumber = len(chunks) for chunk in chunks: i += 1 + print(i) # 返回一个数量为 0 的列表,数据类型为声音 shape[1] - outputAudioData = np.zeros((0, audioData.shape[1])) + # 得到一块音频区间 audioChunk = audioData[int(chunk[0] * samplesPerFrame):int(chunk[1] * samplesPerFrame)] @@ -5572,6 +5576,7 @@ def run(self): # 将这个数列乘以 2 ,变成2轴数列,就能用于双声道 mask = np.repeat(premask[:, np.newaxis], 2, axis=1) # make the fade-envelope mask stereo # 淡入 + # print(outputAudioData[0:0 + AUDIO_FADE_ENVELOPE_SIZE]) outputAudioData[0:0 + AUDIO_FADE_ENVELOPE_SIZE] *= mask # 淡出 outputAudioData[leng - AUDIO_FADE_ENVELOPE_SIZE:leng] *= 1 - mask @@ -5595,8 +5600,11 @@ def run(self): self.copyFrame(lastExistingFrame, outputFrame) # 记一下,原始音频输出帧,输出到哪一个采样点了,这就是下回输出的起始点 outputPointer = endPointer - wavfile.write(self.TEMP_FOLDER + '/audioNew_' + '%06d' % i + '.wav', SAMPLE_RATE, outputAudioData) - concat.write("file " + "audioNew_" + "%06d" % i + ".wav\n") + print(len(outputAudioData) / 44100) + if len(outputAudioData) >= 44100 * 60 * 10 or i == chunksNumber: + wavfile.write(self.TEMP_FOLDER + '/audioNew_' + '%06d' % i + '.wav', SAMPLE_RATE, outputAudioData) + concat.write("file " + "audioNew_" + "%06d" % i + ".wav\n") + outputAudioData = np.zeros((0, audioData.shape[1])) concat.close() self.print(self.tr('\n\n现在开始合并音频片段\n\n\n'))