KleinPenny commited on
Commit
282a1f2
·
verified ·
1 Parent(s): 0b4b4ac

Update app.py

Browse files

ASR + TTS _ V1

Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -17,7 +17,7 @@ def process_audio(audio_data):
17
  if audio_data is None:
18
  return "No audio provided.", ""
19
 
20
- # 检查 audio_data 是否是元组,并提取数据
21
  if isinstance(audio_data, tuple):
22
  sample_rate, data = audio_data
23
  else:
@@ -49,20 +49,20 @@ def process_audio(audio_data):
49
  recognized_text = "The ASR module is still loading, please press the button again!"
50
  return recognized_text, ""
51
 
52
- # 定义函数以禁用按钮并显示加载指示器
53
  def disable_components():
54
- # 更新 recognized_text 的内容,提示用户正在处理
55
- recognized_text_update = gr.update(value='Voice Recognization Running...')
56
- # 禁用 process_button
57
  process_button_update = gr.update(interactive=False)
58
- # 显示加载动画
59
  loading_animation_update = gr.update(visible=True)
60
  return recognized_text_update, process_button_update, loading_animation_update
61
 
62
- # 定义函数以启用按钮并隐藏加载指示器
63
  def enable_components(recognized_text):
64
  process_button_update = gr.update(interactive=True)
65
- # 隐藏加载动画
66
  loading_animation_update = gr.update(visible=False)
67
  return recognized_text, process_button_update, loading_animation_update
68
 
@@ -142,7 +142,6 @@ def create_interface():
142
  outputs=[],
143
  )
144
 
145
-
146
  # Audio input section
147
  with gr.Row():
148
  audio_input = gr.Audio(
@@ -150,7 +149,7 @@ def create_interface():
150
  type="numpy", # Get audio data and sample rate
151
  label="Say Something..."
152
  )
153
- recognized_text = gr.Textbox(label="Recognized Text",interactive=False)
154
 
155
  # Process audio button
156
  process_button = gr.Button("Process Audio")
 
17
  if audio_data is None:
18
  return "No audio provided.", ""
19
 
20
+ # Check if audio_data is a tuple and extract data
21
  if isinstance(audio_data, tuple):
22
  sample_rate, data = audio_data
23
  else:
 
49
  recognized_text = "The ASR module is still loading, please press the button again!"
50
  return recognized_text, ""
51
 
52
+ # Define a function to disable the button and display a loading indicator
53
  def disable_components():
54
+ # Update recognized_text content, indicating that processing is ongoing
55
+ recognized_text_update = gr.update(value='Voice Recognition Running...')
56
+ # Disable process_button
57
  process_button_update = gr.update(interactive=False)
58
+ # Display loading animation
59
  loading_animation_update = gr.update(visible=True)
60
  return recognized_text_update, process_button_update, loading_animation_update
61
 
62
+ # Define a function to enable the button and hide the loading indicator
63
  def enable_components(recognized_text):
64
  process_button_update = gr.update(interactive=True)
65
+ # Hide loading animation
66
  loading_animation_update = gr.update(visible=False)
67
  return recognized_text, process_button_update, loading_animation_update
68
 
 
142
  outputs=[],
143
  )
144
 
 
145
  # Audio input section
146
  with gr.Row():
147
  audio_input = gr.Audio(
 
149
  type="numpy", # Get audio data and sample rate
150
  label="Say Something..."
151
  )
152
+ recognized_text = gr.Textbox(label="Recognized Text", interactive=False)
153
 
154
  # Process audio button
155
  process_button = gr.Button("Process Audio")