Update ui/tabs.py
Browse files- ui/tabs.py +9 -11
ui/tabs.py
CHANGED
|
@@ -202,9 +202,9 @@ def create_audio_tab(audio_service: AudioService):
|
|
| 202 |
def create_streaming_voice_tab(streaming_service: StreamingVoiceService):
|
| 203 |
"""Tạo tab streaming voice sử dụng Gradio microphone"""
|
| 204 |
|
| 205 |
-
# Create components -
|
| 206 |
(microphone, clear_btn, status_display, state_display,
|
| 207 |
-
transcription, ai_response, tts_output
|
| 208 |
|
| 209 |
def process_audio_stream(audio_data):
|
| 210 |
"""Xử lý audio stream từ microphone"""
|
|
@@ -249,18 +249,16 @@ def create_streaming_voice_tab(streaming_service: StreamingVoiceService):
|
|
| 249 |
# Initial state
|
| 250 |
def get_initial_state():
|
| 251 |
state = streaming_service.get_conversation_state()
|
| 252 |
-
return
|
| 253 |
|
| 254 |
# Load initial state khi tab được mở
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
)
|
| 259 |
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
)
|
| 264 |
def create_image_tab(image_service: ImageService):
|
| 265 |
gr.Markdown("## Phân tích hình ảnh")
|
| 266 |
with gr.Row():
|
|
|
|
| 202 |
def create_streaming_voice_tab(streaming_service: StreamingVoiceService):
|
| 203 |
"""Tạo tab streaming voice sử dụng Gradio microphone"""
|
| 204 |
|
| 205 |
+
# Create components - CHỈ NHẬN 7 GIÁ TRỊ (đã bỏ conversation_state)
|
| 206 |
(microphone, clear_btn, status_display, state_display,
|
| 207 |
+
transcription, ai_response, tts_output) = create_streaming_voice_components()
|
| 208 |
|
| 209 |
def process_audio_stream(audio_data):
|
| 210 |
"""Xử lý audio stream từ microphone"""
|
|
|
|
| 249 |
# Initial state
|
| 250 |
def get_initial_state():
|
| 251 |
state = streaming_service.get_conversation_state()
|
| 252 |
+
return state
|
| 253 |
|
| 254 |
# Load initial state khi tab được mở
|
| 255 |
+
def initialize_tab():
|
| 256 |
+
state = streaming_service.get_conversation_state()
|
| 257 |
+
return "Sẵn sàng - nhấn nút microphone để nói", state
|
|
|
|
| 258 |
|
| 259 |
+
# Khởi tạo giá trị ban đầu
|
| 260 |
+
status_display.value = "Sẵn sàng - nhấn nút microphone để nói"
|
| 261 |
+
state_display.value = streaming_service.get_conversation_state()
|
|
|
|
| 262 |
def create_image_tab(image_service: ImageService):
|
| 263 |
gr.Markdown("## Phân tích hình ảnh")
|
| 264 |
with gr.Row():
|