Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -79,7 +79,8 @@ def transcribe_audio(audio):
|
|
79 |
|
80 |
def audio_to_search(audio):
|
81 |
transcription = transcribe_audio(audio)
|
82 |
-
|
|
|
83 |
|
84 |
# 示例問題
|
85 |
example_queries = [
|
@@ -107,14 +108,14 @@ custom_css = """
|
|
107 |
# 創建Gradio界面
|
108 |
with gr.Blocks(css=custom_css) as iface:
|
109 |
gr.Markdown("# AskCTI")
|
110 |
-
gr.Markdown("
|
111 |
|
112 |
with gr.Row(equal_height=True):
|
113 |
with gr.Column(scale=1, min_width=300):
|
114 |
query_input = gr.Textbox(lines=3, label="文字查詢")
|
115 |
with gr.Row():
|
116 |
submit_btn = gr.Button("查詢")
|
117 |
-
audio_input = gr.Audio(
|
118 |
|
119 |
gr.Markdown("### 範例查詢")
|
120 |
for i in range(0, len(example_queries), 2):
|
@@ -126,11 +127,11 @@ with gr.Blocks(css=custom_css) as iface:
|
|
126 |
)
|
127 |
|
128 |
with gr.Column(scale=2):
|
129 |
-
output = gr.Textbox(lines=20, label="
|
130 |
transcription_output = gr.Textbox(lines=3, label="語音轉錄結果")
|
131 |
|
132 |
submit_btn.click(search_and_format, inputs=[query_input], outputs=[output])
|
133 |
-
audio_input.change(audio_to_search, inputs=[audio_input], outputs=[output, transcription_output])
|
134 |
|
135 |
# 啟動Gradio界面
|
136 |
iface.launch()
|
|
|
79 |
|
80 |
def audio_to_search(audio):
|
81 |
transcription = transcribe_audio(audio)
|
82 |
+
search_results = search_and_format(transcription)
|
83 |
+
return search_results, transcription, transcription
|
84 |
|
85 |
# 示例問題
|
86 |
example_queries = [
|
|
|
108 |
# 創建Gradio界面
|
109 |
with gr.Blocks(css=custom_css) as iface:
|
110 |
gr.Markdown("# AskCTI")
|
111 |
+
gr.Markdown("輸入查詢或使用語音輸入以查詢相關情資威脅情報,將顯示前3個最相關的結果。")
|
112 |
|
113 |
with gr.Row(equal_height=True):
|
114 |
with gr.Column(scale=1, min_width=300):
|
115 |
query_input = gr.Textbox(lines=3, label="文字查詢")
|
116 |
with gr.Row():
|
117 |
submit_btn = gr.Button("查詢")
|
118 |
+
audio_input = gr.Audio(type="filepath", label="語音輸入")
|
119 |
|
120 |
gr.Markdown("### 範例查詢")
|
121 |
for i in range(0, len(example_queries), 2):
|
|
|
127 |
)
|
128 |
|
129 |
with gr.Column(scale=2):
|
130 |
+
output = gr.Textbox(lines=20, label="查詢結果")
|
131 |
transcription_output = gr.Textbox(lines=3, label="語音轉錄結果")
|
132 |
|
133 |
submit_btn.click(search_and_format, inputs=[query_input], outputs=[output])
|
134 |
+
audio_input.change(audio_to_search, inputs=[audio_input], outputs=[output, transcription_output, query_input])
|
135 |
|
136 |
# 啟動Gradio界面
|
137 |
iface.launch()
|