Spaces:
Runtime error
Runtime error
File size: 2,465 Bytes
dfbf35f 7764d0a 6eae4fb b00b7b1 6eae4fb dfbf35f 7764d0a dfbf35f e9e9f10 dfbf35f 66e09ed dfbf35f 66e09ed 7764d0a feb8f3f 7764d0a dfbf35f 7764d0a dfbf35f 7764d0a dfbf35f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
from langchain.llms import HuggingFacePipeline
import torch
from components import pexels, utils
import os, gc
import gradio as gr
from transformers import VitsModel, AutoTokenizer, pipeline
import torch
from transformers import pipeline
os.system("cat /etc/ImageMagick-6/policy.xml | sed 's/none/read,write/g'> /etc/ImageMagick-6/policy.xml")
text_cls = pipeline("text-classification", "ivanlau/language-detection-fine-tuned-on-xlm-roberta-base")
model = VitsModel.from_pretrained("facebook/mms-tts-ind")
tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-ind")
model2 = VitsModel.from_pretrained("facebook/mms-tts-eng")
tokenizer2 = AutoTokenizer.from_pretrained("facebook/mms-tts-eng")
pexels_api_key = os.getenv('pexels_api_key')
def pred(product_name, orientation):
if orientation == "Shorts/Reels/TikTok (1080 x 1920)":
orientation = "potrait"
height = 1920
width = 1080
elif orientation == "Youtube Videos (1920 x 1080)":
orientation = "landscape"
height = 1080
width = 1920
else :
orientation = "square"
height = 1080
width = 1080
folder_name, sentences, length_speech = pexels.generate_videos(product_name, pexels_api_key, orientation, height, width, model, tokenizer, model2, tokenizer2, text_cls)
gc.collect()
utils.combine_videos(folder_name, length_speech)
vid = os.path.join(folder_name,"Final_Ad_Video.mp4")
spe = "x.wav"
utils.combine_audio_video(folder_name, vid, spe, sentences, length_speech)
return ["\n".join(sentences), os.path.join(folder_name, "new_filename.mp4")]
#{'video':os.path.join(folder_name, "Final_Ad_Video.mp4"),
# 'captions':"\n".join(sentences)}
with gr.Blocks() as demo:
gr.Markdown(
"""
# Content [Video] Generator
Create a short video based on your text input using AI
### Note : the video generation takes about 2-4 minutes
"""
)
dimension = gr.Dropdown(
["Shorts/Reels/TikTok (1080 x 1920)", "Facebook/Youtube Videos (1920 x 1080)", "Square (1080 x 1080)"],
label="Video Dimension", info="Choose dimension"
)
product_name = gr.Textbox(label="text story", lines=15, max_lines=100)
captions = gr.Textbox(label="captions")
video = gr.Video()
btn = gr.Button("Submit")
btn.click(pred, inputs=[product_name, dimension], outputs=[captions,video])
demo.launch() |