import gradio as gr from transformers import pipeline import requests import os import time asr = pipeline("automatic-speech-recognition", model="openai/whisper-base.en") def download_screenplay(screenplay): filename = "generated_screenplay.txt" with open(filename, "w", encoding="utf-8") as file: file.write(screenplay) display(HTML(f'Download Screenplay')) def speech_to_text(speech): text = asr(speech)["text"] return text PALM_KEY = "AIzaSyArKo4frsgJqoAiuJJ0GVsiIlDAjqD08z4" cons = """ -elaborate everything -no repetations -add naration - 'Close up': - 'Medium': - 'Wide': Begin your narration with these cues, and let the screenplay unfold based on the user's input. We want to experience the heart-pounding excitement of this crucial match, and you are our guide through this thrilling journey. """ def generate_text(prompt, length=500, genre=None): url = "https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key=" + PALM_KEY headers = { "Content-Type": "application/json", } payload = { "prompt": { "text": cons+prompt+f" Genre: {genre} Length: {length} words.", }, } response = requests.post(url, headers=headers, json=payload) response.raise_for_status() response_json = response.json() return response_json['candidates'][0]['output'] def download_screenplay(screenplay): filename = "generated_screenplay.txt" with open(filename, "w", encoding="utf-8") as file: file.write(screenplay) def submit_feedback(feedback): feedback_message = "Thank you for your feedback! We appreciate your input." return feedback_message demo = gr.Blocks( css=""" .gradio-container {background-color: beige;font-family: Roboto, sans-serif;}footer {visibility: hidden; } .Markdown-body { color: visible;}""" ) with demo: gr.Markdown( """