| | import streamlit as st |
| | import requests |
| | import streamlit.components.v1 as components |
| | from gtts import gTTS |
| | from gtts.lang import tts_langs |
| | from io import BytesIO |
| | import os |
| |
|
| | |
| | st.set_page_config(page_title="ViDraft", layout="wide") |
| |
|
| | |
| | st.sidebar.title("ViDraft") |
| |
|
| | |
| | menus = { |
| | "Home": [], |
| | "Free Stock": ["Template Video", "Search Video", "Search Image"], |
| | "Image": ["Face Swap", "Remove Background", "Compositing"], |
| | "Video": ["Generation", "Talking Face", "Remove Background", "Compositing"], |
| | "Sound": ["TTS(Voice)" ,"Image SFX", "Video SFX"], |
| | "Scripts": [] |
| | } |
| |
|
| | |
| | if 'current_menu' not in st.session_state: |
| | st.session_state['current_menu'] = 'Home' |
| | if 'current_sub_menu' not in st.session_state: |
| | st.session_state['current_sub_menu'] = '' |
| |
|
| | |
| | selected_menu = st.sidebar.selectbox("Menu", list(menus.keys()), key='main_menu') |
| | st.session_state['current_menu'] = selected_menu |
| |
|
| | |
| | if selected_menu in menus: |
| | selected_sub_menu = st.sidebar.selectbox("Sub Menu", [""] + menus[selected_menu], key=f'sub_menu_{selected_menu}') |
| | st.session_state['current_sub_menu'] = selected_sub_menu |
| | else: |
| | st.session_state['current_sub_menu'] = '' |
| |
|
| |
|
| | |
| | if selected_menu == "Sound" and selected_sub_menu == "TTS(Voice)": |
| | st.header("Text-to-Speech") |
| | |
| | text = st.text_area("Enter text to synthesize", "Hello, welcome to ViDraft TTS service.") |
| | |
| | |
| | languages_dict = tts_langs() |
| | |
| | two_letter_languages = {code: lang for code, lang in languages_dict.items() if len(code) == 2} |
| |
|
| | |
| | selected_language_code = st.selectbox( |
| | "Choose Language", |
| | options=list(two_letter_languages.keys()), |
| | format_func=lambda x: f"{two_letter_languages[x]} ({x})", |
| | index=list(two_letter_languages.keys()).index('en') |
| | ) |
| | |
| | |
| | if st.button("Synthesize"): |
| | if text: |
| | try: |
| | |
| | tts = gTTS(text=text, lang=selected_language_code, slow=False) |
| | audio_file = BytesIO() |
| | tts.write_to_fp(audio_file) |
| | audio_file.seek(0) |
| | |
| | st.audio(audio_file, format="audio/mp3") |
| | except Exception as e: |
| | st.error(f"Error: {e}") |
| | else: |
| | st.warning("Please enter some text to synthesize.") |
| |
|
| | |
| | |
| | |
| | PEXELS_API_KEY = "5woz23MGx1QrSY0WHFb0BRi29JvbXPu97Hg0xnklYgHUI8G0w23FKH62" |
| |
|
| | def search_images(keyword, per_page=80): |
| | """μ΄λ―Έμ§ κ²μ ν¨μ""" |
| | url = f"https://api.pexels.com/v1/search?query={keyword}&per_page={per_page}" |
| | headers = {"Authorization": PEXELS_API_KEY} |
| | response = requests.get(url, headers=headers).json() |
| | images = [] |
| | if 'photos' in response: |
| | for photo in response['photos']: |
| | images.append(photo['src']['original']) |
| | return images |
| |
|
| | def search_videos(keyword, per_page=80): |
| | """λΉλμ€ κ²μ ν¨μ""" |
| | url = f"https://api.pexels.com/videos/search?query={keyword}&per_page={per_page}" |
| | headers = {"Authorization": PEXELS_API_KEY} |
| | response = requests.get(url, headers=headers).json() |
| | videos = [] |
| | if 'videos' in response: |
| | for video in response['videos']: |
| | videos.append(video['video_files'][0]['link']) |
| | return videos |
| |
|
| | |
| | if selected_menu == "Free Stock" and st.session_state['current_sub_menu'] == "Search Image": |
| | keyword = st.text_input("Enter a keyword to search for images") |
| | if keyword: |
| | images = search_images(keyword) |
| | cols = st.columns(3) |
| | for idx, img in enumerate(images): |
| | with cols[idx % 3]: |
| | st.image(img) |
| |
|
| | |
| | if selected_menu == "Free Stock" and st.session_state['current_sub_menu'] == "Search Video": |
| | keyword = st.text_input("Enter a keyword to search for videos") |
| | if keyword: |
| | videos = search_videos(keyword) |
| | cols = st.columns(3) |
| | for idx, video in enumerate(videos): |
| | with cols[idx % 3]: |
| | st.video(video) |
| |
|
| | |
| | |
| | if selected_menu == "Image" and st.session_state['current_sub_menu'] == "Remove Background": |
| | st.header("Remove Background") |
| | |
| | components.iframe("https://arxivgpt-vidnuki.hf.space", width=None, height=768, scrolling=True) |
| |
|
| | |
| | if selected_menu == "Image" and st.session_state['current_sub_menu'] == "Compositing": |
| | st.header("Compositing") |
| | |
| | components.iframe("https://arxivgpt-vidistudio.hf.space", width=None, height=1800, scrolling=True) |
| | |
| | |
| | if selected_menu == "Image" and st.session_state['current_sub_menu'] == "Face Swap": |
| | st.header("Face Swap") |
| | |
| | components.iframe("https://arxivgpt-vidifs.hf.space", width=None, height=1800, scrolling=True) |
| |
|
| | |
| | if selected_menu == "Video" and st.session_state['current_sub_menu'] == "Compositing": |
| | st.header("Compositing") |
| | |
| | components.iframe("https://arxivgpt-vidvstudio.hf.space", width=None, height=1800, scrolling=True) |
| | |
| | |
| | if selected_menu == "Video" and st.session_state['current_sub_menu'] == "Remove Background": |
| | st.header("Remove Background") |
| | |
| | components.iframe("https://arxivgpt-vidvback.hf.space", width=None, height=1800, scrolling=True) |
| |
|
| | |
| | |
| | if selected_menu == "Sound" and st.session_state['current_sub_menu'] == "Image SFX": |
| | st.header("Image SFX") |
| | |
| | components.iframe("https://arxivgpt-vidisfx.hf.space", width=None, height=1800, scrolling=True) |
| |
|
| | |
| | if selected_menu == "Sound" and st.session_state['current_sub_menu'] == "Video SFX": |
| | st.header("Video SFX") |
| | |
| | components.iframe("https://arxivgpt-vidvsfx.hf.space", width=None, height=1800, scrolling=True) |
| | |
| | |
| | |
| | if selected_menu == "Home": |
| | st.image("banner2.jpg", use_column_width=True) |
| | st.header("Welcome to ViDraft") |
| | st.header("'Create Contents, ViDraft Value-UP'") |
| |
|
| | |
| | welcome_text = """ |
| | Welcome to our dynamic platform, where creativity meets technology across a vast spectrum of multimedia services. Our service offers an extensive array of options for every multimedia need: |
| | |
| | - **Home**: Start your journey here with us, where innovation meets functionality. |
| | - **Free Stock**: Dive into our rich collection of template videos, search for the perfect video or image to complement your project. |
| | - **Image**: Explore our advanced image services including AI-powered generation, facial recognition, inpainting, background removal, and our comprehensive image studio. |
| | - **Video**: Unleash your creativity with video generation, talking face animations, background removal, and access to our state-of-the-art video studio. |
| | - **Sound**: Enhance your projects with video sound effects (SFX), curated video music, text-to-speech (TTS) services, image SFX, and image music integration. |
| | - **Scripts**: Access a wide range of scripting tools and resources to bring your stories to life. |
| | |
| | Join us to transform your creative ideas into reality with cutting-edge technology designed for creators, by creators. |
| | |
| | -Contact: arxivgpt@gmail.com / Powered by ArXivGPT, Huggingface, Gradio, Streamlit |
| | """ |
| | st.write(welcome_text) |
| |
|
| | |
| | image_files = [ |
| | "ViDraft-Video-Templet.png", |
| | "ViDraft-Video-search.png", |
| | "ViDraft-Image-search.png", |
| | "ViDraft-TTS.png", |
| | "ViDraft-image-remove background.png", |
| | "ViDraft-video-remove-back.png", |
| | "ViDraft-video-comp.png", |
| | "ViDraft-image-comp.png", |
| | "ViDraft-image-face swap.png", |
| | "ViDraft-image-sfx.png", |
| | "ViDraft-video-sfx.png" |
| | ] |
| | |
| | image_texts = [ |
| | "Video Template(OpenAI SORA)", |
| | "Free Stock: Video Search", |
| | "Free Stock: Image Search", |
| | "Multilingual Text to Speech(TTS)", |
| | "Remove image background", |
| | "Remove Video background", |
| | "Video Compositing", |
| | "Image Compositing", |
| | "Face Swap Image", |
| | "Image SFX", |
| | "Video SFX" |
| | ] |
| |
|
| | for i in range(0, len(image_files), 3): |
| | cols = st.columns(3) |
| | for idx, col in enumerate(cols): |
| | if i + idx < len(image_files): |
| | col.image(image_files[i + idx], use_column_width=True) |
| | col.markdown(f"<div style='text-align: center; font-weight: bold; font-size: 20px;'>{image_texts[i + idx]}</div>", unsafe_allow_html=True) |
| |
|
| |
|
| | elif selected_menu == "Free Stock": |
| | |
| | if st.session_state['current_sub_menu'] == "Template Video": |
| | st.header("Template Videos") |
| | st.write("Explore a variety of video templates crafted with the innovative technology of OpenAI SORA. Dive into an immersive experience with samples generated by the cutting-edge AI, showcasing the potential to transform your creative ideas into captivating visual stories.") |
| | |
| | video_files = ["ex1.mp4", "ex2.mp4", "ex3.mp4", "ex4.mp4", "ex5.mp4", "ex6.mp4", "ex7.mp4", "ex8.mp4", "ex9.mp4", "ex10.mp4", "ex11.mp4", "ex12.mp4", "ex13.mp4", "ex14.mp4", "ex15.mp4", "ex16.mp4", "ex17.mp4", "ex18.mp4"] |
| | |
| | cols = st.columns(2) |
| | for index, video_file in enumerate(video_files): |
| | with cols[index % 2]: |
| | st.video(video_file) |
| |
|
| |
|
| |
|
| | |
| |
|
| | |
| | elif selected_menu == "Video": |
| | if st.session_state['current_sub_menu'] == "Generation": |
| | st.header("Video Generation") |
| | st.write("Create videos with our generation tools.") |
| | elif st.session_state['current_sub_menu'] == "Talking Face": |
| | st.header("Talking Face Videos") |
| | st.write("Generate talking face videos from images.") |
| |
|
| | |
| | |
| | elif selected_menu == "Scripts": |
| | st.header("Scripts") |
| | st.write("Script writing tools and resources.") |