BHW commited on
Commit
8637508
·
verified ·
1 Parent(s): 8677091

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -21,11 +21,11 @@ help_en = f"""
21
  """
22
  help_zh_tw = f"""
23
  ### 使用流程:
24
- 1. **選擇標記**: 從下拉選單中選擇一個標記,或選擇“自定義”以輸入自己的標記。
25
  2. **輸入用戶名稱**: 輸入您的用戶名稱,用於生成錄音唯一ID。
26
- 3. **錄製或上傳音頻**: 點擊“錄製音頻”按鈕開始錄音,或上傳現有的音頻文件。每次錄音或上傳文件的最長時間為{MAX_LENGTH}秒。
27
- 4. **提交錄音**: 錄製或上傳完成後,點擊“提交”按鈕保存音頻。
28
- 5. **下載錄音**: 使用提供的下載鏈接下載所有已錄製或上傳的文件。
29
  """
30
 
31
  # Function to save audio with label and speaker name
@@ -68,7 +68,8 @@ def save_audio(audio, dropdown_label, custom_label, speaker_name):
68
  # Create an info message
69
  info_message = f"Recorded audio length: {audio_length:.2f} seconds."
70
 
71
- return uploaded_files[speaker_id], info_message
 
72
 
73
  # Interface design using gr.Blocks
74
  def create_interface():
@@ -97,11 +98,11 @@ def create_interface():
97
  # Create an info display area for feedback messages
98
  info_display = gr.Markdown()
99
 
100
- # Add the info output to display recording length
101
  submit_button.click(
102
  fn=save_audio,
103
  inputs=[audio, label_dropdown, custom_label, speaker_name],
104
- outputs=[file_list, info_display],
105
  )
106
 
107
  # Update file list based on the current speaker
 
21
  """
22
  help_zh_tw = f"""
23
  ### 使用流程:
24
+ 1. **選擇標記**: 從下拉選單中選擇一個標記,或選擇“Custom”以輸入自己的標記。
25
  2. **輸入用戶名稱**: 輸入您的用戶名稱,用於生成錄音唯一ID。
26
+ 3. **錄製或上傳音頻**: 點擊“Record Audio”按鈕開始錄音,或上傳現有的音頻文件。每次錄音或上傳文件的最長時間為{MAX_LENGTH}秒。
27
+ 4. **提交錄音**: 錄製或上傳完成後,點擊“Submit”按鈕保存音頻。
28
+ 5. **下載錄音**: 使用提供的下載連結下載所有已錄製或上傳的文件。
29
  """
30
 
31
  # Function to save audio with label and speaker name
 
68
  # Create an info message
69
  info_message = f"Recorded audio length: {audio_length:.2f} seconds."
70
 
71
+ # Reset the audio input to None
72
+ return uploaded_files[speaker_id], info_message, gr.update(value=None)
73
 
74
  # Interface design using gr.Blocks
75
  def create_interface():
 
98
  # Create an info display area for feedback messages
99
  info_display = gr.Markdown()
100
 
101
+ # Add the info output to display recording length and reset audio
102
  submit_button.click(
103
  fn=save_audio,
104
  inputs=[audio, label_dropdown, custom_label, speaker_name],
105
+ outputs=[file_list, info_display, audio],
106
  )
107
 
108
  # Update file list based on the current speaker