CoolFace
Apppublic

KABURAKURIA/SQLIZER1.0

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
app.py69 linesDownload Raw Back to root
1import os2import edge_tts3import json4import asyncio5import whisper_timestamped as whisper6from utility.script.script_generator import generate_script_fdolly7from utility.audio.audio_generator import generate_audio8from utility.captions.timed_captions_generator import generate_timed_captions9from utility.video.background_video_generator import generate_video_url10from utility.render.render_engine import get_output_media11from utility.video.video_search_query_generator import getVideoSearchQueriesTimed, merge_empty_intervals12import argparse13import torch14from transformers import pipeline15 16# Define the FDolly pipeline17dolly_pipeline = pipeline(model="databricks/dolly-v2-3b",18                            torch_dtype=torch.bfloat16,19                            trust_remote_code=True,20                            device_map="auto")21 22def get_completion_dolly(input):23    system = f"""24    You are Kabura bot25    An expert in html, and css,26    write html with css code for different webpages27    """28    prompt = f"#### System: {system}\n#### User: \n{input}\n\n#### Response from Dolly-v2-3b:"29    print(prompt)30    dolly_response = dolly_pipeline(prompt,31                                    max_new_tokens=50032                                    )33    return dolly_response[0]["generated_text"]34 35if __name__ == "__main__":36    parser = argparse.ArgumentParser(description="Generate a video from a topic.")37    parser.add_argument("topic", type=str, help="The topic for the video")38 39    args = parser.parse_args()40    SAMPLE_TOPIC = args.topic41    SAMPLE_FILE_NAME = "audio_tts.wav"42    VIDEO_SERVER = "pexel"43 44    # Use FDolly to generate the script45    response = get_completion_dolly(SAMPLE_TOPIC)46    print("script: {}".format(response))47 48    asyncio.run(generate_audio(response, SAMPLE_FILE_NAME))49 50    timed_captions = generate_timed_captions(SAMPLE_FILE_NAME)51    print(timed_captions)52 53    search_terms = getVideoSearchQueriesTimed(response, timed_captions)54    print(search_terms)55 56    background_video_urls = None57    if search_terms is not None:58        background_video_urls = generate_video_url(search_terms, VIDEO_SERVER)59        print(background_video_urls)60    else:61        print("No background video")62 63    background_video_urls = merge_empty_intervals(background_video_urls)64 65    if background_video_urls is not None:66        video = get_output_media(SAMPLE_FILE_NAME, timed_captions, background_video_urls, VIDEO_SERVER)67        print(video)68    else:69        print("No video")