Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ pipe = pipeline(
|
|
24 |
hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus-08-2024", token=os.getenv("HF_TOKEN"))
|
25 |
|
26 |
@spaces.GPU
|
27 |
-
def
|
28 |
if inputs is None:
|
29 |
raise gr.Error("μ€λμ€ νμΌμ΄ μ μΆλμ§ μμμ΅λλ€! μμ²μ μ μΆνκΈ° μ μ μ€λμ€ νμΌμ μ
λ‘λνκ±°λ λ
Ήμν΄ μ£ΌμΈμ.")
|
30 |
|
@@ -38,25 +38,11 @@ def transcribe_summarize_and_blog(inputs, task):
|
|
38 |
except Exception as e:
|
39 |
summary_text = f"μμ½ μ€ μ€λ₯κ° λ°μνμ΅λλ€: {e}"
|
40 |
|
41 |
-
# λΈλ‘κ·Έ ν¬μ€ν
μμ± μμ²
|
42 |
-
try:
|
43 |
-
blog_post = hf_client.text_generation(
|
44 |
-
prompt=f"λ€μ λ΄μ©μ κΈ°λ°μΌλ‘ λΈλ‘κ·Έ ν¬μ€ν
μ μμ±ν΄ μ£ΌμΈμ:\n{text}",
|
45 |
-
temperature=0.7
|
46 |
-
)
|
47 |
-
blog_post_text = blog_post if isinstance(blog_post, str) else "λΈλ‘κ·Έ ν¬μ€ν
μ μμ±ν μ μμ΅λλ€."
|
48 |
-
except Exception as e:
|
49 |
-
blog_post_text = f"λΈλ‘κ·Έ κΈ μμ± μ€ μ€λ₯κ° λ°μνμ΅λλ€: {e}"
|
50 |
-
|
51 |
return {
|
52 |
"transcribed_text": text,
|
53 |
-
"summary": summary_text
|
54 |
-
"blog_post": blog_post_text
|
55 |
}
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
css = """
|
61 |
footer {
|
62 |
visibility: hidden;
|
@@ -64,24 +50,24 @@ footer {
|
|
64 |
"""
|
65 |
|
66 |
file_transcribe = gr.Interface(
|
67 |
-
fn=
|
68 |
inputs=[
|
69 |
gr.Audio(sources="upload", type="filepath", label="μ€λμ€ νμΌ"),
|
70 |
gr.Radio(["transcribe", "translate"], label="μμ
", value="transcribe"),
|
71 |
],
|
72 |
-
outputs=["text", "text"
|
73 |
-
title="λ°μμ°κΈ° AI: μμ±μ ν
μ€νΈ λ³ν, μμ½
|
74 |
flagging_mode="never",
|
75 |
)
|
76 |
|
77 |
mf_transcribe = gr.Interface(css=css,
|
78 |
-
fn=
|
79 |
inputs=[
|
80 |
gr.Audio(sources="microphone", type="filepath"),
|
81 |
gr.Radio(["transcribe", "translate"], label="μμ
", value="transcribe"),
|
82 |
],
|
83 |
-
outputs=["text", "text"
|
84 |
-
title="λ°μμ°κΈ° AI: μμ±μ ν
μ€νΈ λ³ν, μμ½
|
85 |
flagging_mode="never",
|
86 |
)
|
87 |
|
@@ -93,3 +79,4 @@ with demo:
|
|
93 |
gr.TabbedInterface([file_transcribe, mf_transcribe], ["μ€λμ€ νμΌ", "λ§μ΄ν¬"])
|
94 |
|
95 |
demo.queue().launch(ssr_mode=False)
|
|
|
|
24 |
hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus-08-2024", token=os.getenv("HF_TOKEN"))
|
25 |
|
26 |
@spaces.GPU
|
27 |
+
def transcribe_summarize(inputs, task):
|
28 |
if inputs is None:
|
29 |
raise gr.Error("μ€λμ€ νμΌμ΄ μ μΆλμ§ μμμ΅λλ€! μμ²μ μ μΆνκΈ° μ μ μ€λμ€ νμΌμ μ
λ‘λνκ±°λ λ
Ήμν΄ μ£ΌμΈμ.")
|
30 |
|
|
|
38 |
except Exception as e:
|
39 |
summary_text = f"μμ½ μ€ μ€λ₯κ° λ°μνμ΅λλ€: {e}"
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
return {
|
42 |
"transcribed_text": text,
|
43 |
+
"summary": summary_text
|
|
|
44 |
}
|
45 |
|
|
|
|
|
|
|
46 |
css = """
|
47 |
footer {
|
48 |
visibility: hidden;
|
|
|
50 |
"""
|
51 |
|
52 |
file_transcribe = gr.Interface(
|
53 |
+
fn=transcribe_summarize,
|
54 |
inputs=[
|
55 |
gr.Audio(sources="upload", type="filepath", label="μ€λμ€ νμΌ"),
|
56 |
gr.Radio(["transcribe", "translate"], label="μμ
", value="transcribe"),
|
57 |
],
|
58 |
+
outputs=["text", "text"], # λ³νλ ν
μ€νΈ, μμ½ μΆλ ₯
|
59 |
+
title="λ°μμ°κΈ° AI: μμ±μ ν
μ€νΈ λ³ν, μμ½ μλ μμ±",
|
60 |
flagging_mode="never",
|
61 |
)
|
62 |
|
63 |
mf_transcribe = gr.Interface(css=css,
|
64 |
+
fn=transcribe_summarize,
|
65 |
inputs=[
|
66 |
gr.Audio(sources="microphone", type="filepath"),
|
67 |
gr.Radio(["transcribe", "translate"], label="μμ
", value="transcribe"),
|
68 |
],
|
69 |
+
outputs=["text", "text"], # λ³νλ ν
μ€νΈ, μμ½ μΆλ ₯
|
70 |
+
title="λ°μμ°κΈ° AI: μμ±μ ν
μ€νΈ λ³ν, μμ½ μλ μμ±",
|
71 |
flagging_mode="never",
|
72 |
)
|
73 |
|
|
|
79 |
gr.TabbedInterface([file_transcribe, mf_transcribe], ["μ€λμ€ νμΌ", "λ§μ΄ν¬"])
|
80 |
|
81 |
demo.queue().launch(ssr_mode=False)
|
82 |
+
|