artificialguybr commited on
Commit
fe9af9c
1 Parent(s): 3fe4b5c

Delete appf.py

Browse files
Files changed (1) hide show
  1. appf.py +0 -66
appf.py DELETED
@@ -1,66 +0,0 @@
1
- import gradio as gr
2
- import subprocess
3
- import os
4
- from googletrans import Translator
5
- from TTS.api import TTS
6
- from IPython.display import Audio, display
7
- import ffmpeg
8
- import whisper
9
-
10
- def process_video(video, high_quality, target_language):
11
- try:
12
- output_filename = "resized_video.mp4"
13
- if high_quality:
14
- ffmpeg.input(video).output(output_filename, vf='scale=-1:720').run()
15
- video_path = output_filename
16
- else:
17
- video_path = video
18
-
19
- ffmpeg.input(video_path).output('output_audio.wav', acodec='pcm_s24le', ar=48000, map='a').run()
20
-
21
- model = whisper.load_model("base")
22
- result = model.transcribe("output_audio.wav")
23
- whisper_text = result["text"]
24
- whisper_language = result['language']
25
-
26
- language_mapping = {
27
- 'English': 'en',
28
- 'Spanish': 'es',
29
- 'French': 'fr',
30
- 'German': 'de',
31
- 'Italian': 'it',
32
- 'Portuguese': 'pt',
33
- 'Polish': 'pl',
34
- 'Turkish': 'tr',
35
- 'Russian': 'ru',
36
- 'Dutch': 'nl',
37
- 'Czech': 'cs',
38
- 'Arabic': 'ar',
39
- 'Chinese (Simplified)': 'zh-cn'
40
- }
41
- target_language_code = language_mapping[target_language]
42
- translator = Translator()
43
- translated_text = translator.translate(whisper_text, src=whisper_language, dest=target_language_code).text
44
-
45
- tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1", gpu=True)
46
- tts.tts_to_file(translated_text, speaker_wav='output_audio.wav', file_path="output_synth.wav", language=target_language_code)
47
-
48
- subprocess.run(f"python inference.py --face {video_path} --audio 'output_synth.wav' --outfile 'output_high_qual.mp4'", shell=True)
49
-
50
- return "output_high_qual.mp4"
51
-
52
- except Exception as e:
53
- return str(e)
54
-
55
- iface = gr.Interface(
56
- fn=process_video,
57
- inputs=[
58
- gr.Video(),
59
- gr.inputs.Checkbox(label="High Quality"),
60
- gr.inputs.Dropdown(choices=["English", "Spanish", "French", "German", "Italian", "Portuguese", "Polish", "Turkish", "Russian", "Dutch", "Czech", "Arabic", "Chinese (Simplified)"], label="Target Language for Dubbing")
61
- ],
62
- outputs=gr.outputs.File(),
63
- live=False
64
- )
65
-
66
- iface.launch(share=True)