TDN-M commited on
Commit
850f5fb
1 Parent(s): b146ca4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -0
app.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import os
4
+
5
+ API_URL = "https://api-inference.huggingface.co/models/capleaf/viXTTS"
6
+ headers = {"Authorization": f"Bearer {os.getenv('HF_API_KEY')}"}
7
+
8
+ def query(payload):
9
+ response = requests.post(API_URL, headers=headers, json=payload)
10
+ return response.content
11
+
12
+ def create_audio(text):
13
+ audio_bytes = query({"inputs": text})
14
+ return audio_bytes
15
+
16
+ def create_image(description):
17
+ # Placeholder function for image creation
18
+ return "https://via.placeholder.com/150"
19
+
20
+ def generate_content(description):
21
+ # Placeholder function for content generation
22
+ return "Generated content based on: " + description
23
+
24
+ def create_video(audio_url, image_url):
25
+ # Placeholder function for video creation
26
+ return "https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4"
27
+
28
+ def main():
29
+ with gr.Blocks() as demo:
30
+ with gr.Row():
31
+ gr.Markdown("# MC Ảo VMC")
32
+ gr.Image("https://cdn-avatars.huggingface.co/v1/production/uploads/64e5535467a759dd7143007b/RY63ugBHSWTtSK8mT59j4.png")
33
+
34
+ with gr.Row():
35
+ gr.Markdown("""
36
+ Dự án "MC Ảo VMC" là một ứng dụng web được xây dựng bằng Gradio, cho phép người dùng tạo video với MC ảo từ hình ảnh và nội dung tuỳ chọn, sử dụng giọng nói tiếng Việt tự nhiên.
37
+ ## Sử dụng
38
+ 1. **Bước 1: Tạo Ảnh:** Nhập mô tả cho ảnh và nhấn nút "Tạo Ảnh".
39
+ 2. **Bước 2: Xây Dựng Nội Dung:** Nhập mô tả nội dung và nhấn nút "Tạo Nội Dung".
40
+ 3. **Bước 3: Phòng Thu:** Tải lên file âm thanh tham chiếu hoặc nhập URL âm thanh tham chiếu và nhấn nút "Tạo Âm Thanh".
41
+ 4. **Bước 4: Tạo Video:** Nhấn nút "Tạo Video" để tạo video từ ảnh, nội dung, và âm thanh đã tạo.
42
+ ## Liên hệ
43
+ Nếu bạn có bất kỳ câu hỏi nào, vui lòng liên hệ [dung.ngt1988@gmail.com](mailto:dung.ngt1988@gmail.com).
44
+ """)
45
+
46
+ with gr.Row():
47
+ gr.Video("https://www.youtube.com/watch?v=YourDemoVideo")
48
+
49
+ with gr.Row():
50
+ description = gr.Textbox(label="Nhập mô tả cho ảnh")
51
+ image_button = gr.Button("Tạo Ảnh")
52
+ image_output = gr.Image()
53
+ image_button.click(fn=create_image, inputs=description, outputs=image_output)
54
+
55
+ with gr.Row():
56
+ content_description = gr.Textbox(label="Nhập mô tả nội dung")
57
+ content_button = gr.Button("Tạo Nội Dung")
58
+ content_output = gr.Textbox()
59
+ content_button.click(fn=generate_content, inputs=content_description, outputs=content_output)
60
+
61
+ with gr.Row():
62
+ audio_file = gr.File(label="Upload file âm thanh tham chiếu", type="binary")
63
+ audio_url_input = gr.Textbox(label="Hoặc nhập URL âm thanh tham chiếu")
64
+ audio_button = gr.Button("Tạo Âm Thanh")
65
+ audio_output = gr.Audio()
66
+ audio_button.click(fn=create_audio, inputs=audio_file, outputs=audio_output)
67
+
68
+ with gr.Row():
69
+ video_button = gr.Button("Tạo Video")
70
+ video_output = gr.Video()
71
+ video_button.click(fn=create_video, inputs=[audio_output, image_output], outputs=video_output)
72
+
73
+ demo.launch()
74
+
75
+ if __name__ == "__main__":
76
+ main()