|
from flask import Flask, render_template, request |
|
|
|
import json |
|
|
|
app = Flask(__name__) |
|
|
|
def summarize_text_1(chunk): |
|
|
|
return chunk[0] if chunk else "" |
|
|
|
def summarize_text_2(chunk): |
|
|
|
return "\n".join(chunk[:2]) if chunk else "" |
|
|
|
def summarize_text_3(chunk): |
|
|
|
return "\n".join(chunk[:3]) if chunk else "" |
|
|
|
def load_transcript_data(): |
|
with open('transcript_data.json', 'r') as file: |
|
transcript_data = json.load(file) |
|
return transcript_data |
|
|
|
@app.route('/', methods=['GET', 'POST']) |
|
def index(): |
|
transcripts = [] |
|
if request.method == 'POST': |
|
video_id = request.form.get('video_id') |
|
language = request.form.get('language') |
|
try: |
|
|
|
|
|
|
|
|
|
chunks = load_transcript_data() |
|
|
|
transcripts = [ |
|
{ |
|
'full_text': '\n'.join("a"), |
|
'summary_1': chunk['summary1'], |
|
'summary_2': chunk['summary2'], |
|
'summary_3': chunk['transcript'], |
|
'timestamp': chunk['start'] |
|
} for chunk in chunks |
|
] |
|
except Exception as e: |
|
transcripts = [{'full_text': f"An error occurred: {str(e)}", 'summary_1': "Error", 'summary_2': "Error", 'summary_3': "Error"}] |
|
return render_template('index.html', transcripts=transcripts) |
|
|
|
if __name__ == '__main__': |
|
app.run(debug=True) |
|
|