datbkpro commited on
Commit
3dd9968
·
verified ·
1 Parent(s): eb12ae2

Update ui/tabs.py

Browse files
Files changed (1) hide show
  1. 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 - SỬA: sử dụng components mới
206
  (microphone, clear_btn, status_display, state_display,
207
- transcription, ai_response, tts_output, conversation_state) = create_streaming_voice_components()
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 "Sẵn sàng - nhấn nút microphone để nói", state
253
 
254
  # Load initial state khi tab được mở
255
- status_display.change(
256
- lambda: "Sẵn sàng - nhấn nút microphone để nói",
257
- outputs=[status_display]
258
- )
259
 
260
- state_display.change(
261
- get_initial_state,
262
- outputs=[state_display]
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():