ruslanmv commited on
Commit
16645c3
·
1 Parent(s): a6caa91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -44,9 +44,7 @@ def video_to_translate(file_obj,initial_language,final_language):
44
  elif final_language == "German":
45
  lang='de'
46
  elif final_language == "Japanese":
47
- lang='ja'
48
- elif final_language == "Chinese":
49
- lang='zh-CN'
50
  print(lang)
51
  # init the Google API translator
52
  translator = Translator()
@@ -61,12 +59,13 @@ def video_to_translate(file_obj,initial_language,final_language):
61
  # adding audio to the video clip
62
  new_audioclip = CompositeAudioClip([audioclip])
63
  videoclip.audio = new_audioclip
64
- videoclip.write_videofile("new_filename.mp4")
 
65
  #return 'audio.wav'
66
- return 'new_filename.mp4'
67
 
68
  initial_language = gr.inputs.Dropdown(["English","Italian","Japanese","Russian","Spanish","German"])
69
- final_language = gr.inputs.Dropdown([ "Russian","Italian","Spanish","German","English","Japanese","Chinese"])
70
 
71
 
72
  gr.Interface(fn = video_to_translate,
@@ -74,17 +73,16 @@ gr.Interface(fn = video_to_translate,
74
  outputs = 'video',
75
  verbose = True,
76
  title = 'Video Translator',
77
- description = 'A simple application that translates from English, Italian, Japanese, Russian, Spanish, and German video files to Italian, Spanish, Russian, English, Japanese and Chinese. Upload your own file, or click one of the examples to load them. Wait one minute to process.',
78
  article =
79
  '''<div>
80
  <p style="text-align: center"> All you need to do is to upload the mp4 file and hit submit, then wait for compiling. After that click on Play/Pause for listing to the video. The video is saved in an mp4 format.
81
  For more information visit <a href="https://ruslanmv.com/">ruslanmv.com</a>
82
  </p>
83
  </div>''',
84
- #examples=[['obama.mp4',"English",'Spanish'],
85
- # ['obama.mp4',"English",'Italian'],
86
- # ['obama.mp4',"English",'German'],
87
- # ['obama.mp4',"English",'Japanese'],
88
- # ['obama.mp4',"English",'Chinese']
89
- # ]
90
  ).launch()
 
44
  elif final_language == "German":
45
  lang='de'
46
  elif final_language == "Japanese":
47
+ lang='ja'
 
 
48
  print(lang)
49
  # init the Google API translator
50
  translator = Translator()
 
59
  # adding audio to the video clip
60
  new_audioclip = CompositeAudioClip([audioclip])
61
  videoclip.audio = new_audioclip
62
+ new_video="video_translated_"+lang+".mp4"
63
+ videoclip.write_videofile(new_video)
64
  #return 'audio.wav'
65
+ return new_video
66
 
67
  initial_language = gr.inputs.Dropdown(["English","Italian","Japanese","Russian","Spanish","German"])
68
+ final_language = gr.inputs.Dropdown([ "Russian","Italian","Spanish","German","English","Japanese"])
69
 
70
 
71
  gr.Interface(fn = video_to_translate,
 
73
  outputs = 'video',
74
  verbose = True,
75
  title = 'Video Translator',
76
+ description = 'A simple application that translates from English, Italian, Japanese, Russian, Spanish, and German video files to Italian, Spanish, Russian, English and Japanese. Upload your own file, or click one of the examples to load them. Wait one minute to process.',
77
  article =
78
  '''<div>
79
  <p style="text-align: center"> All you need to do is to upload the mp4 file and hit submit, then wait for compiling. After that click on Play/Pause for listing to the video. The video is saved in an mp4 format.
80
  For more information visit <a href="https://ruslanmv.com/">ruslanmv.com</a>
81
  </p>
82
  </div>''',
83
+ examples=[['obama.mp4',"English",'Spanish'],
84
+ ['obama.mp4',"English",'Italian'],
85
+ ['obama.mp4',"English",'German'],
86
+ ['obama.mp4',"English",'Japanese']
87
+ ]
 
88
  ).launch()