Spaces:
Build error
Build error
File size: 1,181 Bytes
5fa12b5 2aee5b9 7f6f0cf 5fa12b5 7f6f0cf 5fa12b5 7f6f0cf 5fa12b5 7f6f0cf 5fa12b5 7f6f0cf 5fa12b5 7f6f0cf 5fa12b5 7f6f0cf edc7289 |
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 |
import gradio as gr
import moviepy.editor as mp
import numpy as np
import IPython.display as ipd
import librosa
import soundfile as sf
from gtts import gTTS
from io import BytesIO
# function to convert English audio to Hindi
def convert_to_hindi(audio):
tts = gTTS(audio, lang='hi')
audio = tts.get_wav_data()
return audio
# function to extract audio from video and dub it to Hindi
def dub_video(video_file):
# extract audio from video
video = mp.VideoFileClip(video_file)
audio = video.audio
audio_array = audio.to_soundarray()
# convert audio to Hindi
audio_text = librosa.core.to_text(audio_array)
audio_hindi = convert_to_hindi(audio_text)
# add Hindi audio to video
audio_hindi = mp.AudioFileClip(BytesIO(audio_hindi))
video_dubbed = video.set_audio(audio_hindi)
return video_dubbed
# Gradio interface
def dub_video_interface(inputs):
video_file = inputs[0]
video_dubbed = dub_video(video_file)
return video_dubbed
# run the Gradio interface
gr.Interface(fn=dub_video_interface, inputs=gr.Video(label="Upload a video"), outputs=gr.Video(label="Dubbed Video"),title="Auto Dubbing").launch() |