Spaces:
Sleeping
Sleeping
Update.app.py
Browse files
app.py
CHANGED
|
@@ -1,50 +1,48 @@
|
|
| 1 |
-
# app.py
|
| 2 |
-
|
| 3 |
import gradio as gr
|
| 4 |
import speech_recognition as sr
|
| 5 |
from transformers import pipeline
|
| 6 |
from datetime import datetime
|
| 7 |
|
| 8 |
-
# μμ½κΈ° μ΄κΈ°ν
|
| 9 |
summarizer = pipeline("summarization", model="t5-small")
|
| 10 |
|
| 11 |
-
# μμ±
|
| 12 |
-
def
|
| 13 |
recognizer = sr.Recognizer()
|
| 14 |
with sr.AudioFile(audio) as source:
|
| 15 |
audio_data = recognizer.record(source)
|
| 16 |
try:
|
| 17 |
text = recognizer.recognize_google(audio_data, language="ko-KR")
|
| 18 |
except:
|
| 19 |
-
return "μμ± μΈμ μ€ν¨", "", ""
|
| 20 |
|
| 21 |
summary = summarizer(text, max_length=100, min_length=30, do_sample=False)[0]['summary_text']
|
| 22 |
-
|
| 23 |
now = datetime.now().strftime("%Y-%m-%d %H:%M")
|
| 24 |
-
minutes = f"""
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
- λ μ§: {now}
|
| 28 |
-
- νμ μμ½:
|
| 29 |
{summary}
|
| 30 |
|
| 31 |
-
- μ 체 λ΄μ©:
|
| 32 |
{text}
|
| 33 |
"""
|
| 34 |
return text, summary, minutes
|
| 35 |
|
| 36 |
-
# Gradio UI ꡬμ±
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
gr.
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
)
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import speech_recognition as sr
|
| 3 |
from transformers import pipeline
|
| 4 |
from datetime import datetime
|
| 5 |
|
| 6 |
+
# μμ½κΈ° μ΄κΈ°ν (λ λμ λͺ¨λΈλ‘ κ΅μ²΄ κ°λ₯)
|
| 7 |
summarizer = pipeline("summarization", model="t5-small")
|
| 8 |
|
| 9 |
+
# μμ± νμΌ β ν
μ€νΈ β μμ½ β νμλ‘
|
| 10 |
+
def transcribe_and_summarize(audio):
|
| 11 |
recognizer = sr.Recognizer()
|
| 12 |
with sr.AudioFile(audio) as source:
|
| 13 |
audio_data = recognizer.record(source)
|
| 14 |
try:
|
| 15 |
text = recognizer.recognize_google(audio_data, language="ko-KR")
|
| 16 |
except:
|
| 17 |
+
return "β οΈ μμ± μΈμ μ€ν¨", "", ""
|
| 18 |
|
| 19 |
summary = summarizer(text, max_length=100, min_length=30, do_sample=False)[0]['summary_text']
|
|
|
|
| 20 |
now = datetime.now().strftime("%Y-%m-%d %H:%M")
|
| 21 |
+
minutes = f"""π νμλ‘
|
| 22 |
+
- π λ μ§: {now}
|
| 23 |
+
- π§ μμ½:
|
|
|
|
|
|
|
| 24 |
{summary}
|
| 25 |
|
| 26 |
+
- π£ μ 체 λ΄μ©:
|
| 27 |
{text}
|
| 28 |
"""
|
| 29 |
return text, summary, minutes
|
| 30 |
|
| 31 |
+
# μ΅μ Gradio UI κ΅¬μ± (Blocks μ¬μ©)
|
| 32 |
+
with gr.Blocks(title="νμλ‘ μλ μμ±κΈ°") as demo:
|
| 33 |
+
gr.Markdown("## ποΈ νμ μμ± β ν
μ€νΈ & μμ½ μλ μμ±κΈ°")
|
| 34 |
+
gr.Markdown("π¬ μμ± μ
λ ₯λ§μΌλ‘ νμλ‘μ΄ μλ μμ±λ©λλ€. (iPad/PC λͺ¨λ μ§μ)")
|
| 35 |
+
|
| 36 |
+
with gr.Row():
|
| 37 |
+
audio_input = gr.Audio(sources=["microphone", "upload"], type="filepath", label="π§ μμ± μ
λ ₯ (λ§μ΄ν¬ λλ νμΌ μ
λ‘λ)")
|
| 38 |
+
|
| 39 |
+
with gr.Row():
|
| 40 |
+
text_output = gr.Textbox(label="π μ 체 ν
μ€νΈ", lines=5)
|
| 41 |
+
summary_output = gr.Textbox(label="π§ μμ½λ¬Έ", lines=3)
|
| 42 |
+
minutes_output = gr.Textbox(label="π νμλ‘ (볡μ¬/μ μ₯μ©)", lines=10)
|
| 43 |
+
|
| 44 |
+
run_button = gr.Button("π νμλ‘ μμ±")
|
| 45 |
+
|
| 46 |
+
run_button.click(fn=transcribe_and_summarize, inputs=audio_input, outputs=[text_output, summary_output, minutes_output])
|
| 47 |
+
|
| 48 |
+
demo.launch()
|