VMCBeta / app.py
TDN-M's picture
Create app.py
850f5fb verified
raw
history blame
No virus
3.43 kB
import gradio as gr
import requests
import os
API_URL = "https://api-inference.huggingface.co/models/capleaf/viXTTS"
headers = {"Authorization": f"Bearer {os.getenv('HF_API_KEY')}"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
def create_audio(text):
audio_bytes = query({"inputs": text})
return audio_bytes
def create_image(description):
# Placeholder function for image creation
return "https://via.placeholder.com/150"
def generate_content(description):
# Placeholder function for content generation
return "Generated content based on: " + description
def create_video(audio_url, image_url):
# Placeholder function for video creation
return "https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4"
def main():
with gr.Blocks() as demo:
with gr.Row():
gr.Markdown("# MC Ảo VMC")
gr.Image("https://cdn-avatars.huggingface.co/v1/production/uploads/64e5535467a759dd7143007b/RY63ugBHSWTtSK8mT59j4.png")
with gr.Row():
gr.Markdown("""
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.
## Sử dụng
1. **Bước 1: Tạo Ảnh:** Nhập mô tả cho ảnh và nhấn nút "Tạo Ảnh".
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".
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".
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.
## Liên hệ
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).
""")
with gr.Row():
gr.Video("https://www.youtube.com/watch?v=YourDemoVideo")
with gr.Row():
description = gr.Textbox(label="Nhập mô tả cho ảnh")
image_button = gr.Button("Tạo Ảnh")
image_output = gr.Image()
image_button.click(fn=create_image, inputs=description, outputs=image_output)
with gr.Row():
content_description = gr.Textbox(label="Nhập mô tả nội dung")
content_button = gr.Button("Tạo Nội Dung")
content_output = gr.Textbox()
content_button.click(fn=generate_content, inputs=content_description, outputs=content_output)
with gr.Row():
audio_file = gr.File(label="Upload file âm thanh tham chiếu", type="binary")
audio_url_input = gr.Textbox(label="Hoặc nhập URL âm thanh tham chiếu")
audio_button = gr.Button("Tạo Âm Thanh")
audio_output = gr.Audio()
audio_button.click(fn=create_audio, inputs=audio_file, outputs=audio_output)
with gr.Row():
video_button = gr.Button("Tạo Video")
video_output = gr.Video()
video_button.click(fn=create_video, inputs=[audio_output, image_output], outputs=video_output)
demo.launch()
if __name__ == "__main__":
main()