Add application file
Browse files- app.py +12 -6
- requirements.txt +3 -1
app.py
CHANGED
@@ -495,7 +495,7 @@ class AutoRAGChatApp:
|
|
495 |
μμ± μΏΌλ¦¬ μ²λ¦¬
|
496 |
|
497 |
Args:
|
498 |
-
audio: λ
Ήμλ μ€λμ€ λ°μ΄ν°
|
499 |
chat_history: λν κΈ°λ‘
|
500 |
|
501 |
Returns:
|
@@ -505,10 +505,16 @@ class AutoRAGChatApp:
|
|
505 |
return "", chat_history
|
506 |
|
507 |
try:
|
508 |
-
|
|
|
|
|
|
|
509 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_file:
|
510 |
temp_path = temp_file.name
|
511 |
-
|
|
|
|
|
|
|
512 |
|
513 |
print(f"[STT] μμ μ€λμ€ νμΌ μμ±: {temp_path}")
|
514 |
|
@@ -591,9 +597,9 @@ class AutoRAGChatApp:
|
|
591 |
# μ±ν
μΈν°νμ΄μ€
|
592 |
chatbot = gr.Chatbot(
|
593 |
label="λν λ΄μ©",
|
594 |
-
bubble_full_width=False,
|
595 |
height=500,
|
596 |
-
show_copy_button=True
|
|
|
597 |
)
|
598 |
|
599 |
with gr.Tabs() as input_tabs:
|
@@ -614,7 +620,7 @@ class AutoRAGChatApp:
|
|
614 |
audio_input = gr.Audio(
|
615 |
label="λ§μ΄ν¬ μ
λ ₯",
|
616 |
sources=["microphone"],
|
617 |
-
type="
|
618 |
format="wav"
|
619 |
)
|
620 |
voice_submit_btn = gr.Button("μμ± μ§λ¬Έ μ μ‘", variant="primary")
|
|
|
495 |
μμ± μΏΌλ¦¬ μ²λ¦¬
|
496 |
|
497 |
Args:
|
498 |
+
audio: λ
Ήμλ μ€λμ€ λ°μ΄ν° (numpy λ°°μ΄: (μν, μ±λ))
|
499 |
chat_history: λν κΈ°λ‘
|
500 |
|
501 |
Returns:
|
|
|
505 |
return "", chat_history
|
506 |
|
507 |
try:
|
508 |
+
import numpy as np
|
509 |
+
import scipy.io.wavfile as wav
|
510 |
+
|
511 |
+
# numpy λ°°μ΄μ WAV νμΌλ‘ μ μ₯
|
512 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_file:
|
513 |
temp_path = temp_file.name
|
514 |
+
# μνλ§ λ μ΄νΈμ μ€λμ€ λ°μ΄ν°λ₯Ό WAV νμΌλ‘ μ μ₯
|
515 |
+
sr, data = audio
|
516 |
+
# 16λΉνΈ PCM νμμΌλ‘ λ³ν
|
517 |
+
wav.write(temp_path, sr, data.astype(np.int16))
|
518 |
|
519 |
print(f"[STT] μμ μ€λμ€ νμΌ μμ±: {temp_path}")
|
520 |
|
|
|
597 |
# μ±ν
μΈν°νμ΄μ€
|
598 |
chatbot = gr.Chatbot(
|
599 |
label="λν λ΄μ©",
|
|
|
600 |
height=500,
|
601 |
+
show_copy_button=True,
|
602 |
+
type="messages"
|
603 |
)
|
604 |
|
605 |
with gr.Tabs() as input_tabs:
|
|
|
620 |
audio_input = gr.Audio(
|
621 |
label="λ§μ΄ν¬ μ
λ ₯",
|
622 |
sources=["microphone"],
|
623 |
+
type="numpy",
|
624 |
format="wav"
|
625 |
)
|
626 |
voice_submit_btn = gr.Button("μμ± μ§λ¬Έ μ μ‘", variant="primary")
|
requirements.txt
CHANGED
@@ -11,4 +11,6 @@ transformers>=4.34.0
|
|
11 |
langchain-openai>=0.0.2
|
12 |
openai>=1.0.0
|
13 |
docling>=0.1.3
|
14 |
-
requests>=2.28.0
|
|
|
|
|
|
11 |
langchain-openai>=0.0.2
|
12 |
openai>=1.0.0
|
13 |
docling>=0.1.3
|
14 |
+
requests>=2.28.0
|
15 |
+
scipy>=1.10.0
|
16 |
+
numpy>=1.23.0
|