-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
39 lines (32 loc) · 1.24 KB
/
app.py
File metadata and controls
39 lines (32 loc) · 1.24 KB
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
from flask import Flask, render_template, request, redirect, url_for, flash
import gemini_summarize
from werkzeug.utils import secure_filename
import whisper
import os
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = 'static/audio'
@app.route('/')
def index():
return render_template("index.html", summary="", transcription="")
@app.route("/", methods=["POST"])
def summary():
transcript = request.form['transcript']
summary = gemini_summarize.get_summary(transcript)
return render_template("index.html", summary=summary)
@app.route('/upload', methods=['POST'])
def upload_audio():
if 'audio_file' not in request.files:
flash('No file part')
return redirect(request.url)
file = request.files['audio_file']
if file.filename == '':
flash('No selected file')
return redirect(request.url)
if file:
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
model = whisper.load_model("base")
transcription = model.transcribe(os.path.join(app.config['UPLOAD_FOLDER'], filename))
return render_template("index.html", summary="", transcription=transcription["text"])
if __name__ == '__main__':
app.run()