Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,6 @@ import hashlib
|
|
| 8 |
uploaded_files = []
|
| 9 |
help_en = """
|
| 10 |
### Usage Instructions:
|
| 11 |
-
|
| 12 |
1. **Select a Label**: Choose a label from the dropdown menu, or select "Custom" to enter your own label.
|
| 13 |
2. **Enter User Name**: Input your user name, which will be used to generate a unique ID for your recordings.
|
| 14 |
3. **Record Audio**: Click the "Record Audio" button to start recording. The maximum length for each recording is 1 second.
|
|
@@ -17,7 +16,6 @@ help_en = """
|
|
| 17 |
"""
|
| 18 |
help_zh_tw = """
|
| 19 |
### 使用流程:
|
| 20 |
-
|
| 21 |
1. **選擇標記**: 從下拉選單中選擇一個標記,或選擇“自定義”以輸入自己的標記。
|
| 22 |
2. **輸入用戶名稱**: 輸入您的用戶名稱,用於生成錄音唯一ID。
|
| 23 |
3. **錄製音頻**: 點擊“錄製音頻”按鈕開始錄音。每次錄音的最長時間為1秒。
|
|
@@ -64,8 +62,11 @@ def save_audio(audio, dropdown_label, custom_label, speaker_name):
|
|
| 64 |
# Create an info message
|
| 65 |
info_message = f"Recorded audio length: {audio_length:.2f} seconds."
|
| 66 |
|
| 67 |
-
#
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
# Interface design using gr.Blocks
|
| 71 |
def create_interface():
|
|
@@ -88,18 +89,20 @@ def create_interface():
|
|
| 88 |
# Create a list to display all uploaded files
|
| 89 |
file_list = gr.Files(label="Download your recordings")
|
| 90 |
|
|
|
|
|
|
|
|
|
|
| 91 |
# Add the info output to display recording length
|
| 92 |
submit_button.click(
|
| 93 |
fn=save_audio,
|
| 94 |
inputs=[audio, label_dropdown, custom_label, speaker_name],
|
| 95 |
-
outputs=[file_list
|
| 96 |
)
|
| 97 |
|
| 98 |
-
# Add
|
| 99 |
gr.Markdown(help_en)
|
| 100 |
gr.Markdown(help_zh_tw)
|
| 101 |
|
| 102 |
-
|
| 103 |
return demo
|
| 104 |
|
| 105 |
# Launch the interface
|
|
|
|
| 8 |
uploaded_files = []
|
| 9 |
help_en = """
|
| 10 |
### Usage Instructions:
|
|
|
|
| 11 |
1. **Select a Label**: Choose a label from the dropdown menu, or select "Custom" to enter your own label.
|
| 12 |
2. **Enter User Name**: Input your user name, which will be used to generate a unique ID for your recordings.
|
| 13 |
3. **Record Audio**: Click the "Record Audio" button to start recording. The maximum length for each recording is 1 second.
|
|
|
|
| 16 |
"""
|
| 17 |
help_zh_tw = """
|
| 18 |
### 使用流程:
|
|
|
|
| 19 |
1. **選擇標記**: 從下拉選單中選擇一個標記,或選擇“自定義”以輸入自己的標記。
|
| 20 |
2. **輸入用戶名稱**: 輸入您的用戶名稱,用於生成錄音唯一ID。
|
| 21 |
3. **錄製音頻**: 點擊“錄製音頻”按鈕開始錄音。每次錄音的最長時間為1秒。
|
|
|
|
| 62 |
# Create an info message
|
| 63 |
info_message = f"Recorded audio length: {audio_length:.2f} seconds."
|
| 64 |
|
| 65 |
+
# Display the info message using gr.Info
|
| 66 |
+
gr.Info(info_message, duration=5)
|
| 67 |
+
|
| 68 |
+
# Return the list of all file paths for download
|
| 69 |
+
return uploaded_files
|
| 70 |
|
| 71 |
# Interface design using gr.Blocks
|
| 72 |
def create_interface():
|
|
|
|
| 89 |
# Create a list to display all uploaded files
|
| 90 |
file_list = gr.Files(label="Download your recordings")
|
| 91 |
|
| 92 |
+
# Create an info display area
|
| 93 |
+
info_display = gr.Info()
|
| 94 |
+
|
| 95 |
# Add the info output to display recording length
|
| 96 |
submit_button.click(
|
| 97 |
fn=save_audio,
|
| 98 |
inputs=[audio, label_dropdown, custom_label, speaker_name],
|
| 99 |
+
outputs=[file_list],
|
| 100 |
)
|
| 101 |
|
| 102 |
+
# Add usage instructions in both English and Chinese
|
| 103 |
gr.Markdown(help_en)
|
| 104 |
gr.Markdown(help_zh_tw)
|
| 105 |
|
|
|
|
| 106 |
return demo
|
| 107 |
|
| 108 |
# Launch the interface
|