| import datetime |
| import gradio as gr |
| import numpy as np |
| import os |
|
|
| from paddlespeech.cli.tts.infer import TTSExecutor |
|
|
| |
| def greet(name, file): |
|
|
| print(file) |
|
|
| |
| wavname = f"{datetime.datetime.now().strftime('%Y%m%d%H%M%S')}.wav" |
| tts = TTSExecutor() |
| tts(text=name, output=wavname) |
| output_file = f"results/{datetime.datetime.now().strftime('%Y%m%d%H%M%S')}.mp4" |
|
|
| |
| ckpt = os.path.join(os.path.dirname(__file__), "checkpoints/wav2lip.pth") |
| audio = os.path.join(os.path.dirname(__file__), wavname) |
| out = os.path.join(os.path.dirname(__file__), output_file) |
| print(ckpt) |
| print(audio) |
| print(out) |
| os.system(f"python3.10 ./inference.py --checkpoint_path {ckpt} --face_det_batch_size 1 --face {file} --audio {audio} --outfile={out}") |
| |
| |
|
|
| return wavname, out |
|
|
|
|
|
|
|
|
| demo = gr.Interface( |
| fn=greet, |
| |
| inputs=[gr.Text(placeholder="输入要转的文本"), gr.Image(type="filepath")], |
| |
| outputs=[gr.Audio(), gr.Video(label="Processed Video")], |
| ) |
|
|
| if __name__ == "__main__": |
| demo.launch() |
|
|