Spaces:
Runtime error
Runtime error
aa
Browse files
app.py
CHANGED
@@ -37,6 +37,11 @@ def make_return_message(state):
|
|
37 |
{message_string}
|
38 |
"""
|
39 |
|
|
|
|
|
|
|
|
|
|
|
40 |
def summarize_text(state):
|
41 |
|
42 |
def modify_text(state):
|
@@ -164,45 +169,58 @@ with gr.Blocks() as app:
|
|
164 |
"title_history" : [],
|
165 |
"summarize_history" : []
|
166 |
})
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
inputs = gr.Audio(source="microphone", type="filepath", show_label=
|
188 |
|
189 |
debug_field = gr.Textbox(show_label=False,label="", placeholder="ใใใซๆๅญ่ตทใใใๅบใพใ")
|
190 |
|
191 |
inputs.change(fn=transcribe, inputs=[inputs,state], outputs=[debug_field])
|
192 |
inputs.change(lambda :None, None, inputs)
|
193 |
|
194 |
-
|
195 |
-
# btn_test.click(fn=test_method, inputs=None, outputs=[debug_field])
|
196 |
-
|
197 |
-
btn_summerize = gr.Button("่ฆ็ดใใคใใ")
|
198 |
btn_summerize.click(fn=summarize_text, inputs=state, outputs=[debug_field])
|
199 |
|
200 |
btn_summerize = gr.Button("ใฏใใใใผใใซใณใใผ")
|
201 |
btn_summerize.click(fn=copy_clipborad, inputs=debug_field, outputs=None)
|
202 |
|
203 |
-
btn_memory_clear = gr.Button("ใฏใชใขใใ")
|
204 |
-
btn_memory_clear.click(fn=memory_clear, inputs=state, outputs=debug_field)
|
205 |
-
|
206 |
# btn_memory_clear = gr.Button("test")
|
207 |
# btn_memory_clear.click(fn=test_m, inputs=state, outputs=debug_field)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
app.launch(auth=auth)
|
|
|
37 |
{message_string}
|
38 |
"""
|
39 |
|
40 |
+
def summarize_text_from_text(state,txt):
|
41 |
+
init_state(state)
|
42 |
+
state["message_history"] = txt
|
43 |
+
return summarize_text(state)
|
44 |
+
|
45 |
def summarize_text(state):
|
46 |
|
47 |
def modify_text(state):
|
|
|
169 |
"title_history" : [],
|
170 |
"summarize_history" : []
|
171 |
})
|
172 |
+
gr.Markdown(
|
173 |
+
"""
|
174 |
+
# TextWriter AI
|
175 |
+
้ณๅฃฐๆๅญใใใ๏ผ่ฆ็ดใใผใซใ
|
176 |
+
""")
|
177 |
+
|
178 |
+
with gr.Tabs():
|
179 |
+
with gr.TabItem("1.้ณๅฃฐๆๅญ่ตทใใโ่ฆ็ด"):
|
180 |
+
# gr.Markdown(
|
181 |
+
# """
|
182 |
+
# #### โ ใ้ณๅฃฐๆๅญ่ตทใใโ่ฆ็ดใใฎไฝฟใๆน
|
183 |
+
# 1. ใ**Record from microphone**ใใๆผใใจ้ฒ้ณใๅงใพใใพใใใกใขใใใใใจใ่ฉฑใใฆใใ ใใ
|
184 |
+
# 2. ใ**Stop recording**ใใง้ฒ้ณใๆญขใใพใ
|
185 |
+
# 3. ๆๅญ่ตทใใใใใใพใ
|
186 |
+
# 4. 1ใ3ใ็นฐใ่ฟใใฆใใใใจใงใ้ณๅฃฐใๆๅญ่ตทใใใใฆใใใพใ
|
187 |
+
# 5. ใ**่ฆ็ดใใคใใ**ใใๆผใใจใChatGPTใ่ชคๅญ่ฑๅญใไฟฎๆญฃใใ่ฆ็ดใใคใใฆใใใพใ
|
188 |
+
|
189 |
+
# โปใใฉใฆใถๆดๆฐใใใจๆ็ซ ใๆถใใใฎใงใๅฟใใใซใณใใใใฆใใ ใใ<br>
|
190 |
+
# โปในใใใ ใจใฏใชใใใใผใใใใพใๅไฝใใฆใใพใใm(_ _)m<br>
|
191 |
+
# โป่ฆ็ดใงใใใฎใฏ1ไธๆๅญใใใใพใงใงใ""")
|
192 |
+
inputs = gr.Audio(source="microphone", type="filepath", show_label=True,label="ใใฟใณใๆผใใฆ่ฉฑใ")
|
193 |
|
194 |
debug_field = gr.Textbox(show_label=False,label="", placeholder="ใใใซๆๅญ่ตทใใใๅบใพใ")
|
195 |
|
196 |
inputs.change(fn=transcribe, inputs=[inputs,state], outputs=[debug_field])
|
197 |
inputs.change(lambda :None, None, inputs)
|
198 |
|
199 |
+
btn_summerize = gr.Button("่ฆ็ดใใ")
|
|
|
|
|
|
|
200 |
btn_summerize.click(fn=summarize_text, inputs=state, outputs=[debug_field])
|
201 |
|
202 |
btn_summerize = gr.Button("ใฏใใใใผใใซใณใใผ")
|
203 |
btn_summerize.click(fn=copy_clipborad, inputs=debug_field, outputs=None)
|
204 |
|
|
|
|
|
|
|
205 |
# btn_memory_clear = gr.Button("test")
|
206 |
# btn_memory_clear.click(fn=test_m, inputs=state, outputs=debug_field)
|
207 |
+
|
208 |
+
with gr.TabItem("2.ๆ็ซ ใณใใโ่ฆ็ด"):
|
209 |
+
# gr.Markdown(
|
210 |
+
# """
|
211 |
+
# #### โกใๆ็ซ ใณใใโ่ฆ็ดใใฎไฝฟใๆน
|
212 |
+
# 1. ใ**ใใใซๆๅญ่ตทใใใๅบใพใ or ่ฆ็ดใใใๆ็ซ ใใใใซ่ฒผใไปใใฆใใ ใใ**ใใฎๆฌใซ่ฆ็ดใใใๆ็ซ ใใณใใ
|
213 |
+
# 2. ใ**ใณใใ็ตๆใซ่ฆ็ดใใคใใ**ใใๆผใใจใChatGPTใ่ชคๅญ่ฑๅญใไฟฎๆญฃใใ่ฆ็ดใใคใใฆใใใพใ
|
214 |
+
|
215 |
+
# โปใใฉใฆใถๆดๆฐใใใจๆ็ซ ใๆถใใใฎใงใๅฟใใใซใณใใใใฆใใ ใใ<br>
|
216 |
+
# โปในใใใ ใจใฏใชใใใใผใใใใพใๅไฝใใฆใใพใใm(_ _)m<br>
|
217 |
+
# โป่ฆ็ดใงใใใฎใฏ1ไธๆๅญใใใใพใงใงใ""")
|
218 |
+
text_copipe_input = gr.Textbox(show_label=False,label="", placeholder="่ฆ็ดใใใๆ็ซ ใใใใซ่ฒผใไปใใฆใใ ใใ")
|
219 |
+
|
220 |
+
btn_summerize = gr.Button("่ฆ็ดใใ")
|
221 |
+
btn_summerize.click(fn=summarize_text_from_text, inputs=[state,text_copipe_input], outputs=[text_copipe_input])
|
222 |
+
|
223 |
+
btn_summerize = gr.Button("ใฏใใใใผใใซใณใใผ")
|
224 |
+
btn_summerize.click(fn=copy_clipborad, inputs=debug_field, outputs=None)
|
225 |
+
|
226 |
app.launch(auth=auth)
|