|
import gradio as gr |
|
import openai |
|
from moviepy.editor import VideoFileClip |
|
import os |
|
|
|
|
|
openai.api_key = os.getenv("OPENAI_API_KEY") |
|
|
|
|
|
def process_video(video): |
|
|
|
clip = VideoFileClip(video) |
|
audio_path = "audio_extracted.wav" |
|
clip.audio.write_audiofile(audio_path) |
|
|
|
|
|
|
|
transcription = "Este es un ejemplo de transcripci贸n extra铆da del audio." |
|
|
|
|
|
response = openai.ChatCompletion.create( |
|
model="gpt-3.5-turbo", |
|
messages=[{"role": "user", "content": transcription}], |
|
) |
|
|
|
return f"Texto procesado: {response['choices'][0]['message']['content']}" |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("## Procesador de Video con ChatGPT") |
|
video_input = gr.Video(label="Sube tu video") |
|
output_text = gr.Textbox(label="Respuesta de ChatGPT") |
|
submit_button = gr.Button("Procesar Video") |
|
|
|
submit_button.click(process_video, inputs=video_input, outputs=output_text) |
|
|
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|