Spaces:
Sleeping
Sleeping
# app.py | |
import gradio as gr | |
import speech_recognition as sr | |
from transformers import pipeline | |
from datetime import datetime | |
# μμ½κΈ° μ΄κΈ°ν | |
summarizer = pipeline("summarization", model="t5-small") | |
# μμ± νμΌμ λ°μ ν μ€νΈ λ³ν β μμ½ β νμλ‘ μμ± | |
def transcribe_and_summarize(audio): | |
recognizer = sr.Recognizer() | |
with sr.AudioFile(audio) as source: | |
audio_data = recognizer.record(source) | |
try: | |
text = recognizer.recognize_google(audio_data, language="ko-KR") | |
except: | |
return "μμ± μΈμ μ€ν¨", "", "" | |
summary = summarizer(text, max_length=100, min_length=30, do_sample=False)[0]['summary_text'] | |
now = datetime.now().strftime("%Y-%m-%d %H:%M") | |
minutes = f""" | |
# νμλ‘ | |
- λ μ§: {now} | |
- νμ μμ½: | |
{summary} | |
- μ 체 λ΄μ©: | |
{text} | |
""" | |
return text, summary, minutes | |
# Gradio UI κ΅¬μ± | |
demo = gr.Interface( | |
fn=transcribe_and_summarize, | |
inputs=gr.Audio(type="filepath", label="π λ§μ΄ν¬λ‘ λ§νμΈμ"), | |
outputs=[ | |
gr.Textbox(label="π μ 체 ν μ€νΈ"), | |
gr.Textbox(label="π§ μμ½λ¬Έ"), | |
gr.Textbox(label="π νμλ‘ (볡μ¬/μ μ₯ κ°λ₯)"), | |
], | |
title="νμλ‘ μλ μμ±κΈ°", | |
description="λ§νλ©΄ ν μ€νΈμ μμ½, νμλ‘μ μλμΌλ‘ μμ±ν΄μ€λλ€. iPad/PC λͺ¨λ μ¬μ© κ°λ₯.", | |
) | |
if __name__ == "__main__": | |
demo.launch() |