Team Ai
Apppublic

WillML/transcript_summarizer

sourceHugging Facemitupdated 4y agoView on Hugging Face
0likes
app.py39 linesDownload Raw Back to root
1import os2# os.system('sudo apt-get update')3# os.system('sudo apt-get install ffmpeg -y')4# os.environ['FFMPEG_BINARY'] = '/usr/bin/ffmpeg'5 6import whisper7import gradio as gr8import requests9 10def save_file(file):11    with open(file.name, "wb") as f:12        f.write(file.getbuffer())13    return file.name14 15def summarize_audio(file, email):16    if file and email:17        with gr.spinner("Generating magic..."):18            file_path = save_file(file)19            model = whisper.load_model("base")20            result = model.transcribe(file_path, fp16=False)21            webhook_url = "https://hooks.zapier.com/hooks/catch/14830394/331xres/"22            payload = {"email": email, "result": result["text"]} 23            requests.post(webhook_url, json=payload)24            os.remove(file_path)25            return "Done!"26    elif not file:27        return "Please upload your file first!"28    else:29        return "Please enter your email first!"30 31iface = gr.Interface(fn=summarize_audio, 32                     inputs=[gr.inputs.File(label="Upload your audio file (.wav)") ,33                             gr.inputs.Textbox(label="Enter your Email")], 34                     outputs="text", 35                     title="Transcript summarizer 🔮", 36                     description="Upload your audio file and we will summarize it for you!")37 38iface.launch()39