File size: 1,357 Bytes
cb9f2ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
# os.system('sudo apt-get update')
# os.system('sudo apt-get install ffmpeg -y')
# os.environ['FFMPEG_BINARY'] = '/usr/bin/ffmpeg'

import whisper
import gradio as gr
import requests

def save_file(file):
    with open(file.name, "wb") as f:
        f.write(file.getbuffer())
    return file.name

def summarize_audio(file, email):
    if file and email:
        with gr.spinner("Generating magic..."):
            file_path = save_file(file)
            model = whisper.load_model("base")
            result = model.transcribe(file_path, fp16=False)
            webhook_url = "https://hooks.zapier.com/hooks/catch/14830394/331xres/"
            payload = {"email": email, "result": result["text"]} 
            requests.post(webhook_url, json=payload)
            os.remove(file_path)
            return "Done!"
    elif not file:
        return "Please upload your file first!"
    else:
        return "Please enter your email first!"

iface = gr.Interface(fn=summarize_audio, 
                     inputs=[gr.inputs.File(label="Upload your audio file (.wav)") ,
                             gr.inputs.Textbox(label="Enter your Email")], 
                     outputs="text", 
                     title="Transcript summarizer 🔮", 
                     description="Upload your audio file and we will summarize it for you!")

iface.launch()