Im programming a video translation API, and I need docker to do that. Ive ran the API on my local windows machine and it works. I need to write down the audio from the mp4 to transcribe it into text.
It already works flawlessly on Windows, but it seems MoviePy isn’t writing the file, and the class where that happens exits right away. I don0t understand why.
This is the code, just in case:
from moviepy.editor import VideoFileClip
from moviepy.editor import AudioFileClip
from scipy.io import wavfile
from noisereduce import reduce_noise
import numpy as np
class split():
def __init__(self, path, id, video):
self.completed = False
self.id = id
self.video = video
self.path = path
self.separar()
def separar(self):
try:
print("......Separating video and audio......")
# Cargar video
video_editor = VideoFileClip(self.video)
length = video_editor.duration
# Separar parte audio
audio_editor = video_editor.audio.subclip(0, length)
# Guardar parte audio como fichero
audiopath = f'{self.path}/{self.id}_audio.wav'
audio_editor.write_audiofile(audiopath, codec="pcm_s16le")
print("IT WORKED YIPPIII")
# Cerrar recursos
video_editor.close()
audio_editor.close()
# Reducir ruido
self.reducir_ruido()
self.completed = True
except Exception as e:
print("Error occurred during audio splitting:", str(e))
self.completed = False
except Error as error:
print("Error ocurred:", str(e))
self.completed = False
def reducir_ruido(self):
try:
print("......Reducing noise......")
# Cargar los datos de audio del archivo guardado
rate, data = wavfile.read(f'{self.path}/{self.id}_audio.wav')
orig_shape = data.shape
data = np.reshape(data, (2, -1))
# Realizar reducción de ruido
reduced_noise = reduce_noise(
I tried changing the codec, i tried doing a -v when startin the container, I tried “falsifying” a clip making a clip that goes from 0 to video_length… and maybe more stuff i dont remember.