我有两个脚本,其中一个脚本拆分一定长度的音频,另一个脚本在每次无声段落时都拆分音频。仅在经过一定时间后,才可以在静音时分割音频吗?我需要在不短于5分钟的时间内分割成大段的视频。
分割脚本时忽略静音:
from pydub import AudioSegment
#from pydub.utils import mediainfo
from pydub.utils import make_chunks
import math
#lac_audio = AudioSegment.from_file("Kalimba.mp3", "mp3")
#flac_audio.export("audio.mp3", format="mp3")
myaudio = AudioSegment.from_file("Kalimba.mp3" , "mp3")
channel_count = myaudio.channels #Get channels
sample_width = myaudio.sample_width #Get sample width
duration_in_sec = len(myaudio) / 1000#Length of audio in sec
sample_rate = myaudio.frame_rate
print "sample_width=", sample_width
print "channel_count=", channel_count
print "duration_in_sec=", duration_in_sec
print "frame_rate=", sample_rate
bit_rate =16 #assumption , you can extract from mediainfo("test.wav") dynamically
wav_file_size = (sample_rate * bit_rate * channel_count * …Run Code Online (Sandbox Code Playgroud) 我对https://www.pycryptodome.org/en/latest/src/examples.html#encrypt-data-with-rsa有疑问
from Crypto.PublicKey import RSA
from Crypto.Random import get_random_bytes
from Crypto.Cipher import AES, PKCS1_OAEP
file_out = open("encrypted_data.bin", "wb")
recipient_key = RSA.import_key(open("receiver.pem").read())
session_key = get_random_bytes(16)
# Encrypt the session key with the public RSA key
cipher_rsa = PKCS1_OAEP.new(recipient_key)
file_out.write(cipher_rsa.encrypt(session_key))
# Encrypt the data with the AES session key
cipher_aes = AES.new(session_key, AES.MODE_EAX)
ciphertext, tag = cipher_aes.encrypt_and_digest(data)
[ file_out.write(x) for x in (cipher.nonce, tag, ciphertext) ]
Run Code Online (Sandbox Code Playgroud)
它说我应该使用cipher.nonce,但cipher在示例中未定义。我应该使用
cipher = AES.new(key, AES.MODE_EAX)
cipher = AES.new(key, AES.MODE_EAX, nonce)
Run Code Online (Sandbox Code Playgroud)
或者是其他东西?我押注于 …
我一直试图转换一些数据,每组中的第一个值是组标识符:
data = [(a, 1, 2), (a, 3, 4), (b, 5, 6)]
Run Code Online (Sandbox Code Playgroud)
成
data = [[(1, 2), (3, 4)], [(5, 6)]]
Run Code Online (Sandbox Code Playgroud)
最简单的方法是什么?提前致谢