Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,20 +53,21 @@ def video_to_translate(file_obj,initial_language,final_language):
|
|
| 53 |
print(lang)
|
| 54 |
# init the Google API translator
|
| 55 |
translator = Translator()
|
| 56 |
-
translation = translator.translate(text, dest=lang)
|
| 57 |
print("-----------Step 2-----------")
|
|
|
|
|
|
|
| 58 |
#translation.text
|
| 59 |
trans=translation.text
|
| 60 |
myobj = gTTS(text=trans, lang=lang, slow=False)
|
| 61 |
-
print("-----------Step
|
| 62 |
myobj.save("audio.wav")
|
| 63 |
# loading audio file
|
| 64 |
-
print("-----------Step
|
| 65 |
audioclip = AudioFileClip("audio.wav")
|
| 66 |
# adding audio to the video clip
|
| 67 |
new_audioclip = CompositeAudioClip([audioclip])
|
| 68 |
videoclip.audio = new_audioclip
|
| 69 |
-
print("-----------Step
|
| 70 |
videoclip.write_videofile("new_filename.mp4")
|
| 71 |
#return 'audio.wav'
|
| 72 |
print("-----------Step Final-----------")
|
|
|
|
| 53 |
print(lang)
|
| 54 |
# init the Google API translator
|
| 55 |
translator = Translator()
|
|
|
|
| 56 |
print("-----------Step 2-----------")
|
| 57 |
+
translation = translator.translate(text, dest=lang)
|
| 58 |
+
print("-----------Step 3-----------")
|
| 59 |
#translation.text
|
| 60 |
trans=translation.text
|
| 61 |
myobj = gTTS(text=trans, lang=lang, slow=False)
|
| 62 |
+
print("-----------Step 4-----------")
|
| 63 |
myobj.save("audio.wav")
|
| 64 |
# loading audio file
|
| 65 |
+
print("-----------Step 5-----------")
|
| 66 |
audioclip = AudioFileClip("audio.wav")
|
| 67 |
# adding audio to the video clip
|
| 68 |
new_audioclip = CompositeAudioClip([audioclip])
|
| 69 |
videoclip.audio = new_audioclip
|
| 70 |
+
print("-----------Step 6-----------")
|
| 71 |
videoclip.write_videofile("new_filename.mp4")
|
| 72 |
#return 'audio.wav'
|
| 73 |
print("-----------Step Final-----------")
|