import glob
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
#import ffmpeg
import sys
from pydub import AudioSegment, effects
import os, random
name="3x3m x3rec, 3x5m x3rec, 2x8m x4rec"
dir_high='d://mp3//repe//mp3_high'
dir_low='d://mp3//repe//mp3_low'
#file1='01 Lady GaGa - Just Dance [Ft. Colby Odonis].mp3'
#file2='06-linkin_park-robot_boy.mp3'
dir_out='d://mp3//repe//result//'
file_out=dir_out+name
start_high_mp3='d://mp3//repe//start_high.mp3'
start_low_mp3 ='d://mp3//repe//start_low.mp3'
mp3_usados=[]
def audio_duration (file):
audio = AudioSegment.from_mp3(file)
audio_duration_seconds = (len(audio) / 1000.0)
return (audio_duration_seconds)
def pick(dir):
added=False
while (added==False) :
random_file=dir+'\\'+random.choice(os.listdir(dir))
if random_file not in mp3_usados:
mp3_usados.append(random_file)
added=True
else:
print ("buscando mp3 no repetido.")
return random_file
def create_audio(dir,seconds,file_out,start_mp3):
audio_duration=0
audio1 = AudioSegment.from_mp3(start_mp3) # 1 sggundo mp3
while audio_duration < seconds:
file2=pick(dir)
audio2=AudioSegment.from_mp3(file2)
res = (audio1 + audio2)
res.export('tmp.mp3', format='mp3')
tmp= AudioSegment.from_mp3('tmp.mp3')
audio_duration = (len(tmp) / 1000.0)
audio1 = AudioSegment.from_mp3('tmp.mp3') # sumado
print ("escribiendo "+file_out)
ffmpeg_extract_subclip('tmp.mp3', 0, seconds, targetname="~tmp.mp3")
#normaliza
sound = AudioSegment.from_mp3('~tmp.mp3')
normalizedsound = effects.normalize(sound)
normalizedsound.export(file_out, format='mp3')
#serie 1
time=180 # 3'
time_r=180 # 3'r
create_audio(dir_high,time, '~audio1_1.mp3','start//3go.mp3')
create_audio(dir_low ,time_r,'~audio1_1r.mp3','start//3r.mp3')
create_audio(dir_high,time, '~audio1_2.mp3','start//3.mp3')
create_audio(dir_low ,time_r,'~audio1_2r.mp3','start//3r.mp3')
create_audio(dir_high,time, '~audio1_3.mp3','start//3.mp3')
create_audio(dir_low ,time_r,'~audio1_3r.mp3','start//3r.mp3')
#serie 2
time=300 # 5'
time_r=180 # 3'r
create_audio(dir_high,time, '~audio2_1.mp3','start//5.mp3')
create_audio(dir_low ,time_r,'~audio2_1r.mp3','start//3r.mp3')
create_audio(dir_high,time, '~audio2_2.mp3','start//5.mp3')
create_audio(dir_low ,time_r,'~audio2_2r.mp3','start//3r.mp3')
create_audio(dir_high,time, '~audio2_3.mp3','start//5.mp3')
create_audio(dir_low ,time_r,'~audio2_3r.mp3','start//3r.mp3')
#serie 3
time=480 # 8'
time_r=240 # 4'r
create_audio(dir_high,time, '~audio3_1.mp3','start//8.mp3')
create_audio(dir_low ,time_r,'~audio3_1r.mp3','start//4r.mp3')
create_audio(dir_high,time, '~audio3_2.mp3','start//8.mp3')
create_audio(dir_low ,time_r,'~audio3_2r.mp3','start//4r.mp3')
#create_audio(dir_high,time, '~audio3_3.mp3',start_high_mp3)
#create_audio(dir_low ,time_r,'~audio2_3r.mp3',start_low_mp3)
#concatena audios
#serie 1:
audio1_1=AudioSegment.from_mp3 ('~audio1_1.mp3')
audio1_2=AudioSegment.from_mp3 ('~audio1_2.mp3')
audio1_3=AudioSegment.from_mp3 ('~audio1_3.mp3')
audio1_1r=AudioSegment.from_mp3('~audio1_1r.mp3')
audio1_2r=AudioSegment.from_mp3('~audio1_2r.mp3')
audio1_3r=AudioSegment.from_mp3('~audio1_3r.mp3')
#serie2
audio2_1=AudioSegment.from_mp3 ('~audio2_1.mp3')
audio2_2=AudioSegment.from_mp3 ('~audio2_2.mp3')
audio2_3=AudioSegment.from_mp3 ('~audio2_3.mp3')
audio2_1r=AudioSegment.from_mp3('~audio2_1r.mp3')
audio2_2r=AudioSegment.from_mp3('~audio2_2r.mp3')
audio2_3r=AudioSegment.from_mp3('~audio2_3r.mp3')
#serie3
audio3_1=AudioSegment.from_mp3 ('~audio3_1.mp3')
audio3_2=AudioSegment.from_mp3 ('~audio3_2.mp3')
#audio3_3=AudioSegment.from_mp3 ('~audio3_3.mp3')
audio3_1r=AudioSegment.from_mp3('~audio3_1r.mp3')
audio3_2r=AudioSegment.from_mp3('~audio3_2r.mp3')
#audio3_3r=AudioSegment.from_mp3('~audio3_3r.mp3')
audio_fin=AudioSegment.from_mp3('start//listo.mp3')
print ( "creando "+file_out +'.mp3')
res = (audio1_1 + audio1_1r + audio1_2+audio1_2r+audio1_3+audio1_3r+ audio2_1 + audio2_1r + audio2_2+audio2_2r+audio2_3+audio1_3r + audio3_1 + audio3_1r + audio3_2+audio3_2r+audio_fin )
res.export(file_out+'.mp3', format='mp3')
#file2=pick(dir_high,180)
#file3=pick(dir_high,180)
#print ("file1: "+file1)
print ("mp3 usados:")
print(mp3_usados)
#log
file = open(dir_out+'mp3.txt', 'w')
for line in mp3_usados:
line=line.replace("//","/")
line=line.replace('d:/mp3/repe/mp3_','')
file.write(line)
file.write("\n")
file.close()
for fl in glob.glob('~*.mp3'):
os.remove(fl)
sys.exit()
sábado, 19 de noviembre de 2022
training repetitions cretor (python)
python
repetionces.py
jueves, 27 de octubre de 2022
linux du.su (uso de disco)
#!/bin/bash file=du_`date +"%y-%m-%d-%H-%M"`.txt du --max-depth=1 -h| sort >$file
lunes, 18 de abril de 2022
Mikrotik change vlan interface
:local fromif "PC-CAPE FO" :local toif "sfp2" :global interfaces [/interface vlan find ]; :foreach interface in=$interfaces do={ :put ("Interface name: " . [/interface get $interface name]) if ([/interface vlan get $interface interface]=fromif) do={ :put ("Interface interface: " . [/interface vlan get $interface interface]) :put "cambio" /interface vlan set [/interface get $interface name] interface=$toif } }
Suscribirse a:
Entradas (Atom)