Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from flask import Flask, render_template, request
|
2 |
import os
|
3 |
import subprocess
|
4 |
from speech_recognition import Recognizer, AudioFile
|
@@ -16,6 +16,9 @@ tokenizer = AutoTokenizer.from_pretrained("csebuetnlp/mT5_multilingual_XLSum", u
|
|
16 |
model = AutoModelForSeq2SeqLM.from_pretrained("csebuetnlp/mT5_multilingual_XLSum")
|
17 |
punct_model = PunctuationModel(model="oliverguhr/fullstop-punctuation-multilingual-sonar-base")
|
18 |
|
|
|
|
|
|
|
19 |
def metin_duzenleme(text):
|
20 |
text = text.strip()
|
21 |
try:
|
@@ -56,7 +59,10 @@ def ses_donusturucu(wav_path):
|
|
56 |
|
57 |
@app.route("/", methods=["GET", "POST"])
|
58 |
def index():
|
|
|
59 |
if request.method == "POST":
|
|
|
|
|
60 |
if "file" not in request.files:
|
61 |
return "Dosya bulunamadı."
|
62 |
file = request.files["file"]
|
@@ -66,17 +72,29 @@ def index():
|
|
66 |
filename = secure_filename(file.filename)
|
67 |
file_path = os.path.join(app.config["yuklenen_dosyalar"], filename)
|
68 |
file.save(file_path)
|
|
|
69 |
|
70 |
wav_path = convert_mp3_to_wav(file_path)
|
|
|
|
|
71 |
raw_text = ses_donusturucu(wav_path)
|
|
|
|
|
72 |
metin = metin_duzenleme(raw_text)
|
73 |
ozet = metin_ozetleme(metin)
|
|
|
74 |
|
75 |
return render_template("index.html", metin=metin, ozet=ozet)
|
76 |
return render_template("index.html")
|
77 |
|
|
|
|
|
|
|
|
|
|
|
78 |
if __name__ == "__main__":
|
79 |
if not os.path.exists(yuklenen_dosyalar):
|
80 |
os.makedirs(yuklenen_dosyalar)
|
81 |
port = int(os.environ.get("PORT", 7860)) # Hugging Face için 7860 port
|
82 |
app.run(host="0.0.0.0", port=port, debug=False)
|
|
|
|
1 |
+
from flask import Flask, render_template, request, jsonify
|
2 |
import os
|
3 |
import subprocess
|
4 |
from speech_recognition import Recognizer, AudioFile
|
|
|
16 |
model = AutoModelForSeq2SeqLM.from_pretrained("csebuetnlp/mT5_multilingual_XLSum")
|
17 |
punct_model = PunctuationModel(model="oliverguhr/fullstop-punctuation-multilingual-sonar-base")
|
18 |
|
19 |
+
# İlerleme durumunu tutacak değişken
|
20 |
+
upload_progress = 0
|
21 |
+
|
22 |
def metin_duzenleme(text):
|
23 |
text = text.strip()
|
24 |
try:
|
|
|
59 |
|
60 |
@app.route("/", methods=["GET", "POST"])
|
61 |
def index():
|
62 |
+
global upload_progress
|
63 |
if request.method == "POST":
|
64 |
+
upload_progress = 10 # Yükleme başladı
|
65 |
+
|
66 |
if "file" not in request.files:
|
67 |
return "Dosya bulunamadı."
|
68 |
file = request.files["file"]
|
|
|
72 |
filename = secure_filename(file.filename)
|
73 |
file_path = os.path.join(app.config["yuklenen_dosyalar"], filename)
|
74 |
file.save(file_path)
|
75 |
+
upload_progress = 40 # Dosya kaydedildi
|
76 |
|
77 |
wav_path = convert_mp3_to_wav(file_path)
|
78 |
+
upload_progress = 60 # Dönüştürme tamamlandı
|
79 |
+
|
80 |
raw_text = ses_donusturucu(wav_path)
|
81 |
+
upload_progress = 80 # Ses tanıma tamamlandı
|
82 |
+
|
83 |
metin = metin_duzenleme(raw_text)
|
84 |
ozet = metin_ozetleme(metin)
|
85 |
+
upload_progress = 100 # Tamamlandı
|
86 |
|
87 |
return render_template("index.html", metin=metin, ozet=ozet)
|
88 |
return render_template("index.html")
|
89 |
|
90 |
+
@app.route("/progress")
|
91 |
+
def progress():
|
92 |
+
global upload_progress
|
93 |
+
return jsonify({"progress": upload_progress})
|
94 |
+
|
95 |
if __name__ == "__main__":
|
96 |
if not os.path.exists(yuklenen_dosyalar):
|
97 |
os.makedirs(yuklenen_dosyalar)
|
98 |
port = int(os.environ.get("PORT", 7860)) # Hugging Face için 7860 port
|
99 |
app.run(host="0.0.0.0", port=port, debug=False)
|
100 |
+
|