Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,16 @@
|
|
| 1 |
# -*- coding: utf-8 -*-
|
| 2 |
"""
|
| 3 |
-
|
| 4 |
-
-
|
| 5 |
-
-
|
| 6 |
-
-
|
|
|
|
| 7 |
"""
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
from datetime import datetime
|
| 11 |
-
|
| 12 |
-
# --------- Environment helpers ---------
|
| 13 |
def _has_cmd(cmd: str) -> bool:
|
| 14 |
return shutil.which(cmd) is not None
|
| 15 |
|
|
@@ -17,274 +18,451 @@ def _pip_install(pkgs):
|
|
| 17 |
subprocess.check_call([sys.executable, "-m", "pip", "install", "--quiet"] + pkgs)
|
| 18 |
|
| 19 |
def _ensure_runtime():
|
| 20 |
-
# ffmpeg
|
| 21 |
-
if not _has_cmd("ffmpeg"):
|
| 22 |
-
try:
|
| 23 |
-
subprocess.run(["apt-get", "update", "-y"], check=False)
|
| 24 |
-
subprocess.run(["apt-get", "install", "-y", "ffmpeg"], check=False)
|
| 25 |
-
except Exception:
|
| 26 |
-
pass
|
| 27 |
-
# python packages (idempotent)
|
| 28 |
need = []
|
| 29 |
for mod, pkg in [
|
| 30 |
-
("torch",
|
| 31 |
-
("transformers",
|
| 32 |
-
("sentencepiece",
|
| 33 |
-
("faster_whisper",
|
| 34 |
-
("pydub",
|
| 35 |
-
("
|
|
|
|
|
|
|
| 36 |
]:
|
| 37 |
-
try:
|
| 38 |
-
|
| 39 |
-
except Exception:
|
| 40 |
-
need.append(pkg)
|
| 41 |
if need:
|
| 42 |
_pip_install(need)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
_ensure_runtime()
|
| 45 |
|
| 46 |
-
# --------- Imports ---------
|
| 47 |
import gradio as gr
|
|
|
|
| 48 |
import torch
|
| 49 |
from pydub import AudioSegment
|
| 50 |
from faster_whisper import WhisperModel
|
| 51 |
from transformers import pipeline, AutoTokenizer
|
|
|
|
| 52 |
|
| 53 |
-
# --------- STT
|
| 54 |
DEFAULT_WHISPER_SIZE = os.getenv("WHISPER_MODEL_SIZE", "small") # tiny/base/small/medium/large-v3
|
| 55 |
device = "cuda" if torch.cuda.is_available() and os.path.exists("/proc/driver/nvidia") else "cpu"
|
| 56 |
compute_type = "float16" if device == "cuda" else "int8"
|
| 57 |
-
|
| 58 |
_asr = WhisperModel(DEFAULT_WHISPER_SIZE, device=device, compute_type=compute_type)
|
| 59 |
|
| 60 |
-
# --------- Summarizer (
|
| 61 |
PRIMARY_SUMM = "gogamza/kobart-summarization"
|
| 62 |
-
FALLBACK_SUMM = "lcw99/t5-base-korean-text-summary"
|
| 63 |
-
|
| 64 |
-
# lazy holders
|
| 65 |
-
_SUMM_MODEL_NAME = PRIMARY_SUMM
|
| 66 |
_tokenizer = None
|
| 67 |
_summarizer = None
|
| 68 |
|
| 69 |
def load_summarizer(model_name: str):
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
if _summarizer is not None and _SUMM_MODEL_NAME == model_name:
|
| 73 |
return
|
| 74 |
_SUMM_MODEL_NAME = model_name
|
| 75 |
_tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True)
|
| 76 |
-
_summarizer = pipeline(
|
| 77 |
-
|
| 78 |
-
model=model_name,
|
| 79 |
-
device=0 if device == "cuda" else -1
|
| 80 |
-
)
|
| 81 |
|
| 82 |
-
# ์ด๊ธฐ ๋ก๋ (์คํจ ์ ํด๋ฐฑ)
|
| 83 |
try:
|
| 84 |
load_summarizer(PRIMARY_SUMM)
|
| 85 |
except Exception:
|
| 86 |
load_summarizer(FALLBACK_SUMM)
|
| 87 |
|
| 88 |
-
# --------- Utils ---------
|
|
|
|
|
|
|
| 89 |
def convert_to_wav(src_path: str) -> str:
|
| 90 |
-
if src_path.lower().endswith(".wav"):
|
| 91 |
-
return src_path
|
| 92 |
if not _has_cmd("ffmpeg"):
|
| 93 |
-
raise RuntimeError("ffmpeg ํ์ (Spaces: apt.txt์ 'ffmpeg'
|
| 94 |
sound = AudioSegment.from_file(src_path)
|
| 95 |
-
fd, tmp_wav = tempfile.mkstemp(suffix=".wav")
|
| 96 |
-
os.close(fd)
|
| 97 |
sound.export(tmp_wav, format="wav")
|
| 98 |
return tmp_wav
|
| 99 |
|
| 100 |
-
def
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
| 104 |
ids = _tokenizer.encode(text, add_special_tokens=False)
|
| 105 |
-
|
| 106 |
-
i = 0
|
| 107 |
-
n = len(ids)
|
| 108 |
-
if n == 0:
|
| 109 |
-
return []
|
| 110 |
while i < n:
|
| 111 |
end = min(i + max_tokens, n)
|
| 112 |
chunk_ids = ids[i:end]
|
| 113 |
chunks.append(_tokenizer.decode(chunk_ids, skip_special_tokens=True))
|
| 114 |
-
if end == n:
|
| 115 |
-
break
|
| 116 |
i = end - overlap if end - overlap > i else end
|
| 117 |
return chunks
|
| 118 |
|
| 119 |
def summarize_text(text: str):
|
| 120 |
-
"""2-pass summarization with token-based chunking and safe params."""
|
| 121 |
-
# 1) chunk by tokens
|
| 122 |
chunks = tokenize_chunks(text, max_tokens=900, overlap=120)
|
| 123 |
-
if not chunks:
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
# 2) partial summaries
|
| 127 |
-
partial_summaries = []
|
| 128 |
for c in chunks:
|
| 129 |
try:
|
| 130 |
-
out = _summarizer(
|
| 131 |
-
c,
|
| 132 |
-
max_length=160,
|
| 133 |
-
min_length=60,
|
| 134 |
-
do_sample=False
|
| 135 |
-
)[0]["summary_text"]
|
| 136 |
except Exception:
|
| 137 |
-
# ํด๋ฐฑ ๋ชจ๋ธ๋ก ์ฌ์๋
|
| 138 |
if _SUMM_MODEL_NAME != FALLBACK_SUMM:
|
| 139 |
load_summarizer(FALLBACK_SUMM)
|
| 140 |
out = _summarizer(c, max_length=160, min_length=60, do_sample=False)[0]["summary_text"]
|
| 141 |
else:
|
| 142 |
-
out = c
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
# 3) meta summary
|
| 146 |
-
combined = "\n".join(partial_summaries)
|
| 147 |
try:
|
| 148 |
-
final = _summarizer(
|
| 149 |
-
combined,
|
| 150 |
-
max_length=180,
|
| 151 |
-
min_length=70,
|
| 152 |
-
do_sample=False
|
| 153 |
-
)[0]["summary_text"]
|
| 154 |
except Exception:
|
| 155 |
-
# ์ต์ข
ํด๋ฐฑ
|
| 156 |
if _SUMM_MODEL_NAME != FALLBACK_SUMM:
|
| 157 |
load_summarizer(FALLBACK_SUMM)
|
| 158 |
final = _summarizer(combined, max_length=180, min_length=70, do_sample=False)[0]["summary_text"]
|
| 159 |
else:
|
| 160 |
-
final = combined[:1000]
|
| 161 |
return final.strip()
|
| 162 |
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
global _asr
|
| 175 |
if whisper_size and whisper_size != DEFAULT_WHISPER_SIZE:
|
| 176 |
try:
|
| 177 |
_asr = WhisperModel(whisper_size, device=device, compute_type=compute_type)
|
| 178 |
except Exception as e:
|
| 179 |
-
return "", "", "", None, f"โ ๏ธ Whisper
|
| 180 |
|
| 181 |
-
#
|
| 182 |
-
|
| 183 |
try:
|
| 184 |
-
load_summarizer(
|
| 185 |
except Exception as e:
|
| 186 |
-
status.append(f"โ ๏ธ ์์ฝ ๋ชจ๋ธ ๋ก๋ ์คํจ({target_model}): {e} โ ํด๋ฐฑ ์ฌ์ฉ")
|
| 187 |
try:
|
| 188 |
load_summarizer(FALLBACK_SUMM)
|
| 189 |
except Exception as e2:
|
| 190 |
-
return "", "", "", None, f"โ ๏ธ ์์ฝ ๋ชจ๋ธ ๋ก๋ ์คํจ
|
| 191 |
|
| 192 |
if not audio_path:
|
| 193 |
-
return "โ ๏ธ ์ค๋์ค
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
-
# STT
|
| 196 |
wav_path = None
|
| 197 |
try:
|
| 198 |
wav_path = convert_to_wav(audio_path)
|
| 199 |
-
|
|
|
|
| 200 |
segments, info = _asr.transcribe(
|
| 201 |
wav_path,
|
| 202 |
-
language=
|
| 203 |
vad_filter=True,
|
| 204 |
beam_size=5
|
| 205 |
)
|
| 206 |
-
|
| 207 |
-
if not
|
| 208 |
-
return "โ ๏ธ ์ธ์๋ ํ
์คํธ
|
| 209 |
except Exception as e:
|
| 210 |
-
return "", "", "", None, f"โ ๏ธ ์์ฑ ์ธ์ ์ค๋ฅ: {e}"
|
| 211 |
finally:
|
| 212 |
if wav_path and wav_path != audio_path and os.path.exists(wav_path):
|
| 213 |
try: os.remove(wav_path)
|
| 214 |
except: pass
|
| 215 |
|
| 216 |
-
#
|
| 217 |
try:
|
| 218 |
-
summary = summarize_text(
|
| 219 |
except Exception as e:
|
| 220 |
-
# ๋ง์ง๋ง ๋ฐฉ์ด
|
| 221 |
try:
|
| 222 |
load_summarizer(FALLBACK_SUMM)
|
| 223 |
-
summary = summarize_text(
|
| 224 |
-
status
|
| 225 |
except Exception as e2:
|
| 226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
-
|
| 229 |
-
minutes = f"""๐ ํ์๋ก
|
| 230 |
-
- ๐ ๋ ์ง: {now}
|
| 231 |
-
- ๐ง ์์ฝ:
|
| 232 |
{summary}
|
| 233 |
|
| 234 |
-
|
| 235 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
"""
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
def clear_all():
|
| 244 |
-
return None, "", "", "", None, ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
|
| 251 |
with gr.Row():
|
| 252 |
-
with gr.Column(scale=1, min_width=
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
)
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
)
|
| 264 |
-
with gr.Row():
|
| 265 |
-
run_btn = gr.Button("์์ฑ", variant="primary")
|
| 266 |
clear_btn = gr.Button("์ด๊ธฐํ")
|
| 267 |
-
|
| 268 |
status_md = gr.Markdown()
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
with gr.
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
|
| 279 |
run_btn.click(
|
| 280 |
-
fn=
|
| 281 |
inputs=[audio_input, whisper_size, auto_detect, summarizer_choice],
|
| 282 |
-
outputs=[text_out, sum_out,
|
| 283 |
)
|
| 284 |
clear_btn.click(
|
| 285 |
-
fn=clear_all,
|
| 286 |
-
|
| 287 |
-
outputs=[audio_input, text_out, sum_out, minutes_out, dl_file, status_md]
|
| 288 |
)
|
| 289 |
|
| 290 |
demo.launch()
|
|
@@ -292,3 +470,4 @@ demo.launch()
|
|
| 292 |
|
| 293 |
|
| 294 |
|
|
|
|
|
|
| 1 |
# -*- coding: utf-8 -*-
|
| 2 |
"""
|
| 3 |
+
Naver-style UI ยท Whisper STT + Structured Minutes
|
| 4 |
+
- Token-based chunking + 2-pass summarization (KoBART โ T5 fallback)
|
| 5 |
+
- KST ์ ๊ทํ(Date/Time), Duration, Title ์์ฑ
|
| 6 |
+
- Decisions / Action Items / Owner / Due / Next Meeting ์ถ์ถ
|
| 7 |
+
- Colab & Hugging Face Spaces ๊ณต์ฉ
|
| 8 |
"""
|
| 9 |
+
import os, sys, subprocess, tempfile, shutil, re, json
|
| 10 |
+
from datetime import datetime, timezone
|
| 11 |
+
from zoneinfo import ZoneInfo
|
| 12 |
|
| 13 |
+
# ---------- Runtime helpers ----------
|
|
|
|
|
|
|
|
|
|
| 14 |
def _has_cmd(cmd: str) -> bool:
|
| 15 |
return shutil.which(cmd) is not None
|
| 16 |
|
|
|
|
| 18 |
subprocess.check_call([sys.executable, "-m", "pip", "install", "--quiet"] + pkgs)
|
| 19 |
|
| 20 |
def _ensure_runtime():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
need = []
|
| 22 |
for mod, pkg in [
|
| 23 |
+
("torch","torch"),
|
| 24 |
+
("transformers","transformers==4.*"),
|
| 25 |
+
("sentencepiece","sentencepiece"),
|
| 26 |
+
("faster_whisper","faster-whisper==1.*"),
|
| 27 |
+
("pydub","pydub"),
|
| 28 |
+
("dateparser","dateparser"),
|
| 29 |
+
("pandas","pandas"),
|
| 30 |
+
("gradio","gradio==4.*"),
|
| 31 |
]:
|
| 32 |
+
try: __import__(mod)
|
| 33 |
+
except Exception: need.append(pkg)
|
|
|
|
|
|
|
| 34 |
if need:
|
| 35 |
_pip_install(need)
|
| 36 |
+
if not _has_cmd("ffmpeg"):
|
| 37 |
+
try:
|
| 38 |
+
subprocess.run(["apt-get","update","-y"], check=False)
|
| 39 |
+
subprocess.run(["apt-get","install","-y","ffmpeg"], check=False)
|
| 40 |
+
except Exception:
|
| 41 |
+
pass
|
| 42 |
|
| 43 |
_ensure_runtime()
|
| 44 |
|
| 45 |
+
# ---------- Imports ----------
|
| 46 |
import gradio as gr
|
| 47 |
+
import pandas as pd
|
| 48 |
import torch
|
| 49 |
from pydub import AudioSegment
|
| 50 |
from faster_whisper import WhisperModel
|
| 51 |
from transformers import pipeline, AutoTokenizer
|
| 52 |
+
import dateparser
|
| 53 |
|
| 54 |
+
# ---------- STT ----------
|
| 55 |
DEFAULT_WHISPER_SIZE = os.getenv("WHISPER_MODEL_SIZE", "small") # tiny/base/small/medium/large-v3
|
| 56 |
device = "cuda" if torch.cuda.is_available() and os.path.exists("/proc/driver/nvidia") else "cpu"
|
| 57 |
compute_type = "float16" if device == "cuda" else "int8"
|
|
|
|
| 58 |
_asr = WhisperModel(DEFAULT_WHISPER_SIZE, device=device, compute_type=compute_type)
|
| 59 |
|
| 60 |
+
# ---------- Summarizer (primary + fallback) ----------
|
| 61 |
PRIMARY_SUMM = "gogamza/kobart-summarization"
|
| 62 |
+
FALLBACK_SUMM = "lcw99/t5-base-korean-text-summary"
|
| 63 |
+
_SUMM_MODEL_NAME = None
|
|
|
|
|
|
|
| 64 |
_tokenizer = None
|
| 65 |
_summarizer = None
|
| 66 |
|
| 67 |
def load_summarizer(model_name: str):
|
| 68 |
+
global _SUMM_MODEL_NAME, _tokenizer, _summarizer
|
| 69 |
+
if _SUMM_MODEL_NAME == model_name and _summarizer is not None:
|
|
|
|
| 70 |
return
|
| 71 |
_SUMM_MODEL_NAME = model_name
|
| 72 |
_tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True)
|
| 73 |
+
_summarizer = pipeline("summarization", model=model_name,
|
| 74 |
+
device=0 if device=="cuda" else -1)
|
|
|
|
|
|
|
|
|
|
| 75 |
|
|
|
|
| 76 |
try:
|
| 77 |
load_summarizer(PRIMARY_SUMM)
|
| 78 |
except Exception:
|
| 79 |
load_summarizer(FALLBACK_SUMM)
|
| 80 |
|
| 81 |
+
# ---------- Utils: audio ----------
|
| 82 |
+
KST = ZoneInfo("Asia/Seoul")
|
| 83 |
+
|
| 84 |
def convert_to_wav(src_path: str) -> str:
|
| 85 |
+
if src_path.lower().endswith(".wav"): return src_path
|
|
|
|
| 86 |
if not _has_cmd("ffmpeg"):
|
| 87 |
+
raise RuntimeError("ffmpeg๊ฐ ํ์ํฉ๋๋ค. (Spaces: apt.txt์ 'ffmpeg')")
|
| 88 |
sound = AudioSegment.from_file(src_path)
|
| 89 |
+
fd, tmp_wav = tempfile.mkstemp(suffix=".wav"); os.close(fd)
|
|
|
|
| 90 |
sound.export(tmp_wav, format="wav")
|
| 91 |
return tmp_wav
|
| 92 |
|
| 93 |
+
def get_audio_minutes(src_path: str) -> float:
|
| 94 |
+
audio = AudioSegment.from_file(src_path)
|
| 95 |
+
return round(len(audio) / 60000.0, 1)
|
| 96 |
+
|
| 97 |
+
# ---------- Utils: summarization ----------
|
| 98 |
+
def tokenize_chunks(text: str, max_tokens: int = 900, overlap: int = 120):
|
| 99 |
+
if not text.strip(): return []
|
| 100 |
ids = _tokenizer.encode(text, add_special_tokens=False)
|
| 101 |
+
if not ids: return []
|
| 102 |
+
chunks = []; i = 0; n = len(ids)
|
|
|
|
|
|
|
|
|
|
| 103 |
while i < n:
|
| 104 |
end = min(i + max_tokens, n)
|
| 105 |
chunk_ids = ids[i:end]
|
| 106 |
chunks.append(_tokenizer.decode(chunk_ids, skip_special_tokens=True))
|
| 107 |
+
if end == n: break
|
|
|
|
| 108 |
i = end - overlap if end - overlap > i else end
|
| 109 |
return chunks
|
| 110 |
|
| 111 |
def summarize_text(text: str):
|
|
|
|
|
|
|
| 112 |
chunks = tokenize_chunks(text, max_tokens=900, overlap=120)
|
| 113 |
+
if not chunks: return ""
|
| 114 |
+
partials = []
|
|
|
|
|
|
|
|
|
|
| 115 |
for c in chunks:
|
| 116 |
try:
|
| 117 |
+
out = _summarizer(c, max_length=160, min_length=60, do_sample=False)[0]["summary_text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
except Exception:
|
|
|
|
| 119 |
if _SUMM_MODEL_NAME != FALLBACK_SUMM:
|
| 120 |
load_summarizer(FALLBACK_SUMM)
|
| 121 |
out = _summarizer(c, max_length=160, min_length=60, do_sample=False)[0]["summary_text"]
|
| 122 |
else:
|
| 123 |
+
out = c
|
| 124 |
+
partials.append(out.strip())
|
| 125 |
+
combined = "\n".join(partials)
|
|
|
|
|
|
|
| 126 |
try:
|
| 127 |
+
final = _summarizer(combined, max_length=180, min_length=70, do_sample=False)[0]["summary_text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
except Exception:
|
|
|
|
| 129 |
if _SUMM_MODEL_NAME != FALLBACK_SUMM:
|
| 130 |
load_summarizer(FALLBACK_SUMM)
|
| 131 |
final = _summarizer(combined, max_length=180, min_length=70, do_sample=False)[0]["summary_text"]
|
| 132 |
else:
|
| 133 |
+
final = combined[:1000]
|
| 134 |
return final.strip()
|
| 135 |
|
| 136 |
+
# ---------- NLP heuristics ----------
|
| 137 |
+
# ๊ธฐ๊ด/๊ณ ๊ฐ์ฌ ๋จ์
|
| 138 |
+
ORG_HINTS = ["๋ณดํ", "์ํ", "์นด๋", "์ฆ๊ถ", "์บํผํ", "์๋ช
", "์๋ณด", "์ฃผ์ํ์ฌ", "ใ"]
|
| 139 |
+
STOPWORDS = set(["๊ทธ๋ฆฌ๊ณ ","ํ์ง๋ง","๊ทธ๋์","๊ทธ๋ฌ๋ฉด","์ ํฌ","์ฐ๋ฆฌ","์ค๋","๋ด์ผ","์ด๋ฒ","๋ค์","ํจ","ํจ.", "ํฉ๋๋ค","ํฉ๋๋ค."])
|
| 140 |
+
|
| 141 |
+
name_pattern = re.compile(r"([๊ฐ-ํฃ]{2,4})(๋|[๊ณผ์ฐจ๋ถ๋]์ฅ|[์ดํ๋ณธ]์ฅ)?")
|
| 142 |
+
due_patterns = [
|
| 143 |
+
r"(์ค๋|๋ด์ผ|๋ชจ๋ |์ด๋ฒ\s*์ฃผ\s*[์ํ์๋ชฉ๊ธํ ์ผ]|๋ค์\s*์ฃผ\s*[์ํ์๋ชฉ๊ธํ ์ผ]|[0-9]{1,2}\s*์\s*[0-9]{1,2}\s*์ผ)(\s*[์ค์ ์คํ]?\s*[0-9]{1,2}\s*์(\s*[0-9]{1,2}\s*๋ถ)?)?\s*(๊น์ง)?",
|
| 144 |
+
r"(๊ธ์ผ๊น์ง|์ฃผ๋ง๊น์ง|์๋ง๊น์ง|๋ถ๊ธฐ๋ง๊น์ง)"
|
| 145 |
+
]
|
| 146 |
+
next_meeting_patterns = [
|
| 147 |
+
r"(๋ค์\s*์ฃผ\s*[์ํ์๋ชฉ๊ธํ ์ผ]\s*[0-9]{1,2}\s*์)",
|
| 148 |
+
r"(๋ค์\s*๋ฏธํ
|์ฌํ์|ํ์\s*ํ์|follow[- ]?up)\s*(์|๋)?\s*(?:[์|์ผ๋ก])?\s*([^\n\.]+)?"
|
| 149 |
+
]
|
| 150 |
+
decision_keywords = ["ํ๊ธฐ๋ก ํจ", "ํ์ ", "์น์ธ", "๊ฒฐ์ ", "ํฉ์"]
|
| 151 |
+
action_markers = ["ํด์ฃผ์ธ์", "ํด ์ฃผ์ธ์", "๋ถํ", "์งํํด", "์งํํ์ธ์", "ํ๊ฒ ์ต๋๋ค", "ํ ๊ฒ์", "ํด์ผ ํฉ๋๋ค", "ํ์ํฉ๋๋ค", "์กฐ์น ๋ฐ๋๋๋ค"]
|
| 152 |
+
|
| 153 |
+
def normalize_datetime_kst(text: str, base_dt: datetime):
|
| 154 |
+
"""์์ฐ์ด ๋ ์ง/์๊ฐ(ํ๊ตญ์ด)์ KST๋ก ์ ๊ทํ"""
|
| 155 |
+
if not text: return None
|
| 156 |
+
dt = dateparser.parse(
|
| 157 |
+
text,
|
| 158 |
+
settings={
|
| 159 |
+
"TIMEZONE": "Asia/Seoul",
|
| 160 |
+
"RETURN_AS_TIMEZONE_AWARE": True,
|
| 161 |
+
"PREFER_DATES_FROM": "future",
|
| 162 |
+
"RELATIVE_BASE": base_dt.astimezone(KST)
|
| 163 |
+
},
|
| 164 |
+
languages=["ko", "en"]
|
| 165 |
+
)
|
| 166 |
+
return dt.astimezone(KST) if dt else None
|
| 167 |
+
|
| 168 |
+
def extract_organizations(text: str):
|
| 169 |
+
orgs = set()
|
| 170 |
+
tokens = re.findall(r"[๊ฐ-ํฃA-Za-z0-9][๊ฐ-ํฃA-Za-z0-9\(\)ใ\.]*", text)
|
| 171 |
+
for t in tokens:
|
| 172 |
+
if any(h in t for h in ORG_HINTS) and len(t) <= 30:
|
| 173 |
+
orgs.add(t.strip(" ."))
|
| 174 |
+
return list(orgs)[:3]
|
| 175 |
+
|
| 176 |
+
def extract_topic(text: str):
|
| 177 |
+
# ๋จ์ ํค์๋ ํ๋ณด: 2~8์, ์ซ์/๋ถ์ฉ์ด ์ ์ธ, ๋น๋ ์์
|
| 178 |
+
words = re.findall(r"[๊ฐ-ํฃA-Za-z0-9]{2,}", text)
|
| 179 |
+
freq = {}
|
| 180 |
+
for w in words:
|
| 181 |
+
if w in STOPWORDS: continue
|
| 182 |
+
if re.match(r"^\d+$", w): continue
|
| 183 |
+
freq[w] = freq.get(w, 0) + 1
|
| 184 |
+
top = sorted(freq.items(), key=lambda x: x[1], reverse=True)[:5]
|
| 185 |
+
return " / ".join([t[0] for t in top]) if top else "ํ์"
|
| 186 |
+
|
| 187 |
+
def build_title(date_dt: datetime, orgs, topic):
|
| 188 |
+
d = date_dt.astimezone(KST).strftime("%Y-%m-%d")
|
| 189 |
+
org = orgs[0] if orgs else "๊ณ ๊ฐ์ฌ"
|
| 190 |
+
top = topic if topic else "ํ์"
|
| 191 |
+
return f"{d} ยท {org} ยท {top}"
|
| 192 |
+
|
| 193 |
+
def split_sentences(text: str):
|
| 194 |
+
# ๊ฐ๋จ ๋ฌธ์ฅ ๋ถ๋ฆฌ
|
| 195 |
+
sents = re.split(r"(?<=[\.!?]|๋ค\.)\s+|\n", text)
|
| 196 |
+
return [s.strip() for s in sents if s.strip()]
|
| 197 |
+
|
| 198 |
+
def find_owner_near(sentence: str):
|
| 199 |
+
# ๋ฌธ์ฅ ๋ด ์ด๋ฆ/์งํจ ํจํด ์ถ์ถ
|
| 200 |
+
m = name_pattern.findall(sentence)
|
| 201 |
+
if not m: return ""
|
| 202 |
+
# ๊ฐ์ฅ ์ฒ์ ๋ฑ์ฅํ ์ด๋ฆ ๋ฐํ
|
| 203 |
+
return m[0][0]
|
| 204 |
+
|
| 205 |
+
def parse_due_in_sentence(sentence: str, base_dt: datetime):
|
| 206 |
+
for pat in due_patterns:
|
| 207 |
+
m = re.search(pat, sentence)
|
| 208 |
+
if m:
|
| 209 |
+
dt = normalize_datetime_kst(m.group(0), base_dt)
|
| 210 |
+
if dt:
|
| 211 |
+
return dt.strftime("%Y-%m-%d %H:%M")
|
| 212 |
+
return ""
|
| 213 |
+
|
| 214 |
+
def extract_decisions(text: str):
|
| 215 |
+
sents = split_sentences(text)
|
| 216 |
+
results = []
|
| 217 |
+
for s in sents:
|
| 218 |
+
if any(k in s for k in decision_keywords):
|
| 219 |
+
results.append(s)
|
| 220 |
+
return results
|
| 221 |
+
|
| 222 |
+
def extract_actions(text: str, base_dt: datetime):
|
| 223 |
+
sents = split_sentences(text)
|
| 224 |
+
rows = []
|
| 225 |
+
for s in sents:
|
| 226 |
+
if any(k in s for k in action_markers):
|
| 227 |
+
owner = find_owner_near(s)
|
| 228 |
+
due = parse_due_in_sentence(s, base_dt)
|
| 229 |
+
task = s
|
| 230 |
+
rows.append({"Task": task, "Owner": owner, "Due": due})
|
| 231 |
+
return rows
|
| 232 |
+
|
| 233 |
+
def extract_next_meeting(text: str, base_dt: datetime):
|
| 234 |
+
sents = split_sentences(text)
|
| 235 |
+
for s in sents:
|
| 236 |
+
if any(re.search(p, s) for p in next_meeting_patterns):
|
| 237 |
+
# ๋ ์ง/์๊ฐ ๊ตฌ๊ฐ๋ง ํ์ฑ ์๋
|
| 238 |
+
dt = None
|
| 239 |
+
for pat in next_meeting_patterns:
|
| 240 |
+
m = re.search(pat, s)
|
| 241 |
+
if m:
|
| 242 |
+
dt = normalize_datetime_kst(m.group(0), base_dt)
|
| 243 |
+
if dt: break
|
| 244 |
+
return s, (dt.strftime("%Y-%m-%d %H:%M") if dt else "")
|
| 245 |
+
return "", ""
|
| 246 |
+
|
| 247 |
+
# ---------- Core ----------
|
| 248 |
+
def transcribe_and_structure(audio_path, whisper_size, auto_detect_lang, summarizer_choice):
|
| 249 |
+
# Whisper reload
|
| 250 |
global _asr
|
| 251 |
if whisper_size and whisper_size != DEFAULT_WHISPER_SIZE:
|
| 252 |
try:
|
| 253 |
_asr = WhisperModel(whisper_size, device=device, compute_type=compute_type)
|
| 254 |
except Exception as e:
|
| 255 |
+
return "", "", "", "", "", None, pd.DataFrame(), pd.DataFrame(), "", "", f"โ ๏ธ Whisper ๋ก๋ ์คํจ: {e}"
|
| 256 |
|
| 257 |
+
# Summarizer select
|
| 258 |
+
target = PRIMARY_SUMM if summarizer_choice == "KoBART" else FALLBACK_SUMM
|
| 259 |
try:
|
| 260 |
+
load_summarizer(target)
|
| 261 |
except Exception as e:
|
|
|
|
| 262 |
try:
|
| 263 |
load_summarizer(FALLBACK_SUMM)
|
| 264 |
except Exception as e2:
|
| 265 |
+
return "", "", "", "", "", None, pd.DataFrame(), pd.DataFrame(), "", "", f"โ ๏ธ ์์ฝ ๋ชจ๋ธ ๋ก๋ ์คํจ: {e2}"
|
| 266 |
|
| 267 |
if not audio_path:
|
| 268 |
+
return "โ ๏ธ ์ค๋์ค ์์", "", "", "", "", None, pd.DataFrame(), pd.DataFrame(), "", "", "โ ๏ธ ์ค๋์ค๋ฅผ ์
๋ก๋ํ๊ฑฐ๋ ๋
น์ํด ์ฃผ์ธ์."
|
| 269 |
+
|
| 270 |
+
# ํ์ผ ๋ฉํ ์์์๊ฐ(์
๋ก๋ ํ์ผ ์์ ์๊ฐ์ผ๋ก ๊ทผ์ฌ) & Duration
|
| 271 |
+
try:
|
| 272 |
+
file_epoch = os.path.getmtime(audio_path)
|
| 273 |
+
file_start = datetime.fromtimestamp(file_epoch, tz=KST)
|
| 274 |
+
except Exception:
|
| 275 |
+
file_start = datetime.now(tz=KST)
|
| 276 |
|
|
|
|
| 277 |
wav_path = None
|
| 278 |
try:
|
| 279 |
wav_path = convert_to_wav(audio_path)
|
| 280 |
+
duration_min = get_audio_minutes(wav_path) # ๋งค์ฐ ๋์
|
| 281 |
+
# STT
|
| 282 |
segments, info = _asr.transcribe(
|
| 283 |
wav_path,
|
| 284 |
+
language=None if auto_detect_lang else "ko",
|
| 285 |
vad_filter=True,
|
| 286 |
beam_size=5
|
| 287 |
)
|
| 288 |
+
full_text = "".join(seg.text for seg in segments).strip()
|
| 289 |
+
if not full_text:
|
| 290 |
+
return "โ ๏ธ ์ธ์๋ ํ
์คํธ ์์", "", "", "", "", duration_min, pd.DataFrame(), pd.DataFrame(), "", "", "โ ๏ธ ์์ฑ ์ธ์ ๊ฒฐ๊ณผ๊ฐ ๋น์ด ์์ต๋๋ค."
|
| 291 |
except Exception as e:
|
| 292 |
+
return "", "", "", "", "", None, pd.DataFrame(), pd.DataFrame(), "", "", f"โ ๏ธ ์์ฑ ์ธ์ ์ค๋ฅ: {e}"
|
| 293 |
finally:
|
| 294 |
if wav_path and wav_path != audio_path and os.path.exists(wav_path):
|
| 295 |
try: os.remove(wav_path)
|
| 296 |
except: pass
|
| 297 |
|
| 298 |
+
# Summary
|
| 299 |
try:
|
| 300 |
+
summary = summarize_text(full_text)
|
| 301 |
except Exception as e:
|
|
|
|
| 302 |
try:
|
| 303 |
load_summarizer(FALLBACK_SUMM)
|
| 304 |
+
summary = summarize_text(full_text)
|
| 305 |
+
status = "โ
์๋ฃ (์์ฝ ๋ชจ๋ธ ํด๋ฐฑ ์ฌ์ฉ)"
|
| 306 |
except Exception as e2:
|
| 307 |
+
summary = ""
|
| 308 |
+
status = f"โ ๏ธ ์์ฝ ์คํจ: {e2}"
|
| 309 |
+
else:
|
| 310 |
+
status = "โ
์๋ฃ"
|
| 311 |
+
|
| 312 |
+
# Date/Time (๋ฐํ ์ค ์๋/์ ๋ ์๊ฐ ์ ๊ทํ ์๋: "์ค๋/๋ด์ผ/8์ 12์ผ 3์" ๋ฑ)
|
| 313 |
+
# ๊ฐ์ฅ ๊ฐํ ์๊ฐ ํํ์ด ์์ผ๋ฉด ๊ทธ๊ฑธ๋ก, ์์ผ๋ฉด ํ์ผ ์์์๊ฐ
|
| 314 |
+
time_candidates = []
|
| 315 |
+
# ๊ฐ๋จํ ์๊ฐ ๋จ์ ์์ง: "์ค๋|๋ด์ผ|๋ชจ๋ |์ด๋ฒ ์ฃผ|๋ค์ ์ฃผ|[0-9]+์ [0-9]+์ผ" ๋ฑ
|
| 316 |
+
for pat in due_patterns + [r"[0-9]{1,2}\s*์\s*[0-9]{1,2}\s*์ผ\s*[์ค์ ์คํ]?\s*[0-9]{1,2}\s*์(\s*[0-9]{1,2}\s*๋ถ)?"]:
|
| 317 |
+
for m in re.finditer(pat, full_text):
|
| 318 |
+
time_candidates.append(m.group(0))
|
| 319 |
+
dt_main = file_start
|
| 320 |
+
for cand in time_candidates:
|
| 321 |
+
dt = normalize_datetime_kst(cand, file_start)
|
| 322 |
+
if dt:
|
| 323 |
+
dt_main = dt
|
| 324 |
+
break
|
| 325 |
+
|
| 326 |
+
# Org/Topic โ Title
|
| 327 |
+
orgs = extract_organizations(full_text)
|
| 328 |
+
topic = extract_topic(full_text)
|
| 329 |
+
title = build_title(dt_main, orgs, topic)
|
| 330 |
+
|
| 331 |
+
# Decisions
|
| 332 |
+
decisions = extract_decisions(full_text)
|
| 333 |
+
decisions_df = pd.DataFrame({"Decision": decisions}) if decisions else pd.DataFrame(columns=["Decision"])
|
| 334 |
+
|
| 335 |
+
# Actions(+Owner/Due)
|
| 336 |
+
actions = extract_actions(full_text, dt_main)
|
| 337 |
+
actions_df = pd.DataFrame(actions) if actions else pd.DataFrame(columns=["Task","Owner","Due"])
|
| 338 |
+
|
| 339 |
+
# Next Meeting
|
| 340 |
+
next_sent, next_dt = extract_next_meeting(full_text, dt_main)
|
| 341 |
+
|
| 342 |
+
# ํ์๋ก ๋ณธ๋ฌธ(๋ณต์ฌ/์ ์ฅ)
|
| 343 |
+
minutes_md = f"""๐ ํ์๋ก
|
| 344 |
+
- ๐ ์ผ์: {dt_main.strftime("%Y-%m-%d %H:%M KST")}
|
| 345 |
+
- โฑ ๊ธธ์ด: {duration_min}๋ถ
|
| 346 |
+
- ๐งพ ์ ๋ชฉ: {title}
|
| 347 |
+
- ๐ข ๊ณ ๊ฐ์ฌ ํ๋ณด: {", ".join(orgs) if orgs else "N/A"}
|
| 348 |
|
| 349 |
+
## ์์ฝ
|
|
|
|
|
|
|
|
|
|
| 350 |
{summary}
|
| 351 |
|
| 352 |
+
## ํต์ฌ ์์ฌ๊ฒฐ์
|
| 353 |
+
{os.linesep.join(["- " + d for d in decisions]) if decisions else "- (์์)"}
|
| 354 |
+
|
| 355 |
+
## ์ก์
์์ดํ
|
| 356 |
+
{os.linesep.join(["- " + a["Task"] + (f" ยท ๋ด๋น: {a['Owner']}" if a.get('Owner') else "") + (f" ยท ๋ง๊ฐ: {a['Due']}" if a.get('Due') else "") for a in actions]) if actions else "- (์์)"}
|
| 357 |
+
|
| 358 |
+
## ๋ค์ ์ผ์
|
| 359 |
+
- {next_sent if next_sent else "(๋ฏธ์ )"}{(" ยท " + next_dt) if next_dt else ""}
|
| 360 |
"""
|
| 361 |
+
|
| 362 |
+
# ๋ค์ด๋ก๋ ํ์ผ
|
| 363 |
+
fd, path = tempfile.mkstemp(suffix=".txt")
|
| 364 |
+
with os.fdopen(fd, "w", encoding="utf-8") as f:
|
| 365 |
+
f.write(minutes_md)
|
| 366 |
+
|
| 367 |
+
return (
|
| 368 |
+
full_text, # ์ ์ฒด ํ
์คํธ
|
| 369 |
+
summary, # ์์ฝ
|
| 370 |
+
title, # ์ ๋ชฉ
|
| 371 |
+
dt_main.strftime("%Y-%m-%d %H:%M KST"), # ์ผ์
|
| 372 |
+
f"{duration_min}", # ๊ธธ์ด(๋ถ)
|
| 373 |
+
path, # ๋ค์ด๋ก๋ ํ์ผ
|
| 374 |
+
decisions_df, # Decisions DF
|
| 375 |
+
actions_df, # Actions DF
|
| 376 |
+
next_sent, # ๋ค์ ์ผ์ ๋ฌธ์ฅ
|
| 377 |
+
next_dt, # ๋ค์ ์ผ์ ์ผ์
|
| 378 |
+
status # ์ํ
|
| 379 |
+
)
|
| 380 |
|
| 381 |
def clear_all():
|
| 382 |
+
return None, "", "", "", "", None, pd.DataFrame(), pd.DataFrame(), "", "", ""
|
| 383 |
+
|
| 384 |
+
# ---------- Naver-like Clean UI ----------
|
| 385 |
+
NAVER_GREEN = "#03C75A"
|
| 386 |
+
CUSTOM_CSS = f"""
|
| 387 |
+
:root {{
|
| 388 |
+
--nv-green: {NAVER_GREEN};
|
| 389 |
+
--nv-bg: #f7f8fa;
|
| 390 |
+
--nv-card: #ffffff;
|
| 391 |
+
--nv-text: #111827;
|
| 392 |
+
--nv-subtext: #6b7280;
|
| 393 |
+
--nv-border: #e5e7eb;
|
| 394 |
+
}}
|
| 395 |
+
body {{ background: var(--nv-bg); }}
|
| 396 |
+
#nv-header {{
|
| 397 |
+
background: var(--nv-green);
|
| 398 |
+
color: #fff; padding: 14px 18px; border-bottom: 1px solid rgba(0,0,0,.06);
|
| 399 |
+
}}
|
| 400 |
+
#nv-wrap {{ max-width: 1100px; margin: 22px auto; padding: 0 12px; }}
|
| 401 |
+
.nv-card {{
|
| 402 |
+
background: var(--nv-card); border: 1px solid var(--nv-border); border-radius: 12px;
|
| 403 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.03); padding: 16px;
|
| 404 |
+
}}
|
| 405 |
+
.nv-actions {{ display:flex; gap:10px; align-items:center; margin-top: 8px; }}
|
| 406 |
+
.nv-btn-primary button {{
|
| 407 |
+
background: var(--nv-green) !important; border-color: var(--nv-green) !important; color: #fff !important;
|
| 408 |
+
}}
|
| 409 |
+
"""
|
| 410 |
|
| 411 |
+
with gr.Blocks(title="ํ์๋ก ์์ฑ๊ธฐ ยท Naver Style", css=CUSTOM_CSS) as demo:
|
| 412 |
+
gr.HTML(f"""
|
| 413 |
+
<div id="nv-header">
|
| 414 |
+
<div style="max-width:1100px;margin:0 auto;display:flex;align-items:center;gap:10px;">
|
| 415 |
+
<div style="font-weight:800;font-size:20px;letter-spacing:-0.2px;">N</div>
|
| 416 |
+
<div style="font-weight:700;">ํ์๋ก ์์ฑ๊ธฐ</div>
|
| 417 |
+
</div>
|
| 418 |
+
</div>
|
| 419 |
+
<div id="nv-wrap">
|
| 420 |
+
""")
|
| 421 |
|
| 422 |
with gr.Row():
|
| 423 |
+
with gr.Column(scale=1, min_width=380):
|
| 424 |
+
gr.HTML('<div class="nv-card"><h3 style="margin:6px 0">์
๋ ฅ</h3>')
|
| 425 |
+
audio_input = gr.Audio(sources=["microphone","upload"], type="filepath", label="์์ฑ ์
๋ก๋ ยท ๋
น์")
|
| 426 |
+
with gr.Row(elem_classes=["nv-actions"]):
|
| 427 |
+
whisper_size = gr.Dropdown(["tiny","base","small","medium","large-v3"],
|
| 428 |
+
value=DEFAULT_WHISPER_SIZE, label="Whisper ๋ชจ๋ธ")
|
| 429 |
+
summarizer_choice = gr.Radio(choices=["KoBART","Korean T5 (fallback)"],
|
| 430 |
+
value="KoBART", label="์์ฝ ๋ชจ๋ธ")
|
| 431 |
+
auto_detect = gr.Checkbox(value=False, label="์ธ์ด ์๋ ๊ฐ์ง(๋ค๊ตญ์ด)")
|
| 432 |
+
with gr.Row(elem_classes=["nv-actions"]):
|
| 433 |
+
run_btn = gr.Button("์์ฑ", elem_classes=["nv-btn-primary"])
|
|
|
|
|
|
|
|
|
|
| 434 |
clear_btn = gr.Button("์ด๊ธฐํ")
|
|
|
|
| 435 |
status_md = gr.Markdown()
|
| 436 |
+
gr.HTML("</div>")
|
| 437 |
+
|
| 438 |
+
with gr.Column(scale=2, min_width=520):
|
| 439 |
+
gr.HTML('<div class="nv-card"><h3 style="margin:6px 0">๊ฒฐ๊ณผ</h3>')
|
| 440 |
+
with gr.Tabs():
|
| 441 |
+
with gr.Tab("์์ฝ/๋ณธ๋ก "):
|
| 442 |
+
sum_out = gr.Textbox(lines=10, label="์์ฝ")
|
| 443 |
+
text_out = gr.Textbox(lines=12, label="์ ์ฒด ํ
์คํธ")
|
| 444 |
+
with gr.Tab("๊ฒฐ์ ยท ์ก์
"):
|
| 445 |
+
decisions_df = gr.Dataframe(headers=["Decision"], datatype=["str"], label="ํต์ฌ ์์ฌ๊ฒฐ์ ", wrap=True)
|
| 446 |
+
actions_df = gr.Dataframe(headers=["Task","Owner","Due"], datatype=["str","str","str"], label="์ก์
์์ดํ
", wrap=True)
|
| 447 |
+
with gr.Tab("๋ฉํ ยท ๋ค์ด๋ก๋"):
|
| 448 |
+
title_out = gr.Textbox(label="์ ๋ชฉ (YYYY-MM-DD ยท ๊ณ ๊ฐ์ฌ ยท ์ฃผ์ )", interactive=False)
|
| 449 |
+
dt_out = gr.Textbox(label="ํ์ ์ผ์(KST)", interactive=False)
|
| 450 |
+
dur_out = gr.Textbox(label="๊ธธ์ด(๋ถ)", interactive=False)
|
| 451 |
+
next_sent_out = gr.Textbox(label="๋ค์ ์ผ์ ๋ฌธ์ฅ", interactive=False)
|
| 452 |
+
next_dt_out = gr.Textbox(label="๋ค์ ์ผ์ ์ผ์", interactive=False)
|
| 453 |
+
dl_file = gr.File(label="ํ์๋ก ๋ค์ด๋ก๋(.txt)", interactive=False)
|
| 454 |
+
gr.HTML("</div>")
|
| 455 |
+
|
| 456 |
+
gr.HTML("</div>") # close wrap
|
| 457 |
|
| 458 |
run_btn.click(
|
| 459 |
+
fn=transcribe_and_structure,
|
| 460 |
inputs=[audio_input, whisper_size, auto_detect, summarizer_choice],
|
| 461 |
+
outputs=[text_out, sum_out, title_out, dt_out, dur_out, dl_file, decisions_df, actions_df, next_sent_out, next_dt_out, status_md]
|
| 462 |
)
|
| 463 |
clear_btn.click(
|
| 464 |
+
fn=clear_all, inputs=None,
|
| 465 |
+
outputs=[audio_input, text_out, sum_out, title_out, dt_out, dur_out, dl_file, decisions_df, actions_df, next_sent_out, next_dt_out, status_md]
|
|
|
|
| 466 |
)
|
| 467 |
|
| 468 |
demo.launch()
|
|
|
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
+
|