Código de Python - Convertidor de archivos de audio.

Imágen de perfil
Val: 712
Bronce
Ha aumentado 1 puesto en Python (en relación al último mes)
Gráfica de Python

Convertidor de archivos de audio.gráfica de visualizaciones


Python

Actualizado el 29 de Mayo del 2021 por Antonio (75 códigos) (Publicado el 23 de Marzo del 2020)
11.094 visualizaciones desde el 23 de Marzo del 2020
El siguiente programa convierte un archivo de audio cargado mediante el botón "BUSCAR ARCHIVO", en un archivo de extensión "wav", "ogg", "mp3", "mp2", "flv", "aiff", "mp4" y "au", seleccionando cualquiera de los correspondientes botones. Generándose el nuevo archivo en el directorio de ejecución (que podrá ser seleccionado con el botón "CARPETA DESTINO".
afc

Requerimientos

Lenguaje: Python
Libtrerías: os, tkinter, threading, pydub
Requisitos: Se requiere tener instalado "FFmpeg".

2.2
estrellaestrellaestrellaestrellaestrella(6)

Actualizado el 30 de Mayo del 2021 (Publicado el 23 de Marzo del 2020)gráfica de visualizaciones de la versión: 2.2
11.095 visualizaciones desde el 23 de Marzo del 2020
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tkinter import *
import tkinter
import threading
from tkinter import messagebox, filedialog
import os
from pydub import AudioSegment
 
def abrir_archivo(ex):
    global audio, nom, audio
    if ex in formatos:
        try:
            if ex == ".mp3":
                audio = AudioSegment.from_mp3(ruta)
            elif ex == ".ogg":
                audio = AudioSegment.from_ogg(ruta)
            elif ex == ".wav":
                audio = AudioSegment.from_wav(ruta)
            elif ex == ".flv":
                audio = AudioSegment.from_flv(ruta)
            else:
                audio = AudioSegment.from_file(ruta)
        except:
            messagebox.showwarning("ERROR","NO PUDO COMPLETARSE LA ACCIÓN")
            etiName.configure(text="NINGÚN ARCHIVO SELECCIONADO")
            nom = ""
            audio = ""
    else:
        messagebox.showwarning("ERROR","Formato no soportado")
        etiName.configure(text="NINGÚN ARCHIVO SELECCIONADO")
        audio = ""
 
def dire():
    currentDir.set(os.getcwd())
 
def busca_archivo():
    global nom, ex, ruta, file
    etiName.configure(text="IMPORTANDO ARCHIVO...")
    if executing == False:
        estat.configure(text="")
        ruta = filedialog.askopenfilename(initialdir="/",title="SELECCIONAR ARCHIVO",filetypes =(("mp3 files","*.mp3")
                                          ,("wav files","*.wav"),("mp4 files","*.mp4"),("flv files","*.flv")
                                          ,("ogg files","*.ogg"),("mp2 files","*.mp2"),("aac files","*.aiff")
                                          ,("au files","*.au"),("M4A files","*.m4a"),("all files","*")))
        if ruta != "":
            file = ruta.split("/")[-1]
            nom,ex = os.path.splitext(file)
            etiName.configure(text=("ARCHIVO SELECCIONADO: "+file))
            abrir_archivo(ex)
        else:
            if file == "" or nom == "":
                etiName.configure(text="NINGÚN ARCHIVO SELECCIONADO")
            else:
                etiName.configure(text=("ARCHIVO SELECCIONADO: "+file))
 
def cambia_dir():
    if executing == False:
        directorio=filedialog.askdirectory()
        if directorio!="":
            os.chdir(directorio)
            currentDir.set(os.getcwd())
 
def convert():
    global executing, file
    if audio != "":
        executing = True
        try:
            estat.configure(text="PROCESO EN CURSO...")
            name = nom+"."+ty
            if name == file:
                name = nom+"(copia)"+"."+ty
            audio.export((name),format=ty)
            estat.configure(text="PROCESO FINALIZADO\nARCHIVO CREADO: "+name)
        except:
            messagebox.showwarning("ERROR","HUBO UN PROBLEMA AL REALIZAR LA OPERACIÓN")
            estat.configure(text="")
        executing=False
 
def inicia(tip):
    global ty
    if executing == False:
        ty=tip
        t = threading.Thread(target=convert)
        t.start()
 
root = tkinter.Tk()
root.title("AUDIO FILE CONVERTER")
root.configure(background="gray40")
root.geometry("700x550")
audio = ""
currentDir=StringVar()
currentDir.set(os.getcwd())
ty = ""
file = ""
executing = False
 
formatos = [".mp3",".mp4",".wav",".ogg",".flv",".aiff",".mp2",".au",".m4a"]
 
#ELEMENTOS
entryDir = Entry(root,textvariable=currentDir,width=116)
entryDir.place(x=0,y=0)
etiName = Label(root,text='NINGÚN ARCHIVO SELECCIONADO',bg="black",
                fg="red",width=91,height=2)
etiName.place(x=26,y=90)
 
btnBusca = Button(root,text='BUSCAR ARCHIVO',activebackground='firebrick1',activeforeground='blue',bg='blue',fg='firebrick1',command=busca_archivo)#
btnBusca.place(x=294,y=158)
 
estat = Label(root,width=91,bg="gray40",fg="white")
estat.place(x=26,y=190)
 
Button(root,text="CARPETA DESTINO",activebackground='white',activeforeground='green',fg='white',bg ='green',command=cambia_dir).place(x=292,y=490)
Button(root,text='EXPORTAR A FORMATO .WAV',activeforeground='red',bg='red',fg='white',width=40,command=lambda:inicia("wav")).place(x=26,y=240)
Button(root,text='EXPORTAR A FORMATO .MP3',activeforeground='red',bg='red',fg='white',width=40,command=lambda:inicia("mp3")).place(x=26,y=290)
Button(root,text='EXPORTAR A FORMATO .FLV',activeforeground='red',bg='red',fg='white',width=40,command=lambda:inicia("flv")).place(x=26,y=340)
Button(root,text='EXPORTAR A FORMATO .OGG',activeforeground='red',bg='red',fg='white',width=40,command=lambda:inicia("ogg")).place(x=380,y=240)
Button(root,text='EXPORTAR A FORMATO .MP2',activeforeground='red',bg='red',fg='white',width=40,command=lambda:inicia("mp2")).place(x=380,y=290)
Button(root,text='EXPORTAR A FORMATO .MP4',activeforeground='red',bg='red',fg='white',width=40,command=lambda:inicia("mp4")).place(x=380,y=340)
Button(root,text='EXPORTAR A FORMATO .AAC',activeforeground='red',bg='red',fg='white',width=40,command=lambda:inicia("aiff")).place(x=26,y=390)
Button(root,text='EXPORTAR A FORMATO    .AU',activeforeground='red',bg='red',fg='white',width=40,command=lambda:inicia("au")).place(x=380,y=390)
 
root.mainloop()



Comentarios sobre la versión: 2.2 (6)

Alejandro
24 de Marzo del 2020
estrellaestrellaestrellaestrellaestrella
No ha dejado ningún comentario
Responder
Imágen de perfil
4 de Abril del 2020
estrellaestrellaestrellaestrellaestrella
Muy bueno!!!
Responder
Imágen de perfil
4 de Abril del 2020
estrellaestrellaestrellaestrellaestrella
Gracias.
Responder
camaleon
9 de Abril del 2020
estrellaestrellaestrellaestrellaestrella
excelente
Responder
Imágen de perfil
9 de Abril del 2020
estrellaestrellaestrellaestrellaestrella
Gracias.
Responder
Pablo
21 de Abril del 2020
estrellaestrellaestrellaestrellaestrella
exelente apoyo muchas gracias
Responder

Comentar la versión: 2.2

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s6058