Spaces:
Build error
Build error
| 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() | |