Spaces:
Build error
Build error
work on digits interface
Browse files
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 💻
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 2.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
|
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 2.9b23
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
app.py
CHANGED
|
@@ -37,12 +37,13 @@ def push_record():
|
|
| 37 |
def save_record(language,text,record):
|
| 38 |
# Save text and its corresponding record to flag
|
| 39 |
|
| 40 |
-
if language!=None and language!='Choose language':
|
| 41 |
lang_id = DEFAULT_LANGS[language]
|
| 42 |
text =text.strip()
|
| 43 |
|
| 44 |
# Write audio to file
|
| 45 |
audio_output_filename = os.path.join(AUDIO_PATH,f'{len(os.listdir(AUDIO_PATH))}.wav')
|
|
|
|
| 46 |
wavf.write(audio_output_filename,record[0],record[1])
|
| 47 |
|
| 48 |
if not os.path.exists(DATA_FILE):
|
|
@@ -60,7 +61,9 @@ def save_record(language,text,record):
|
|
| 60 |
|
| 61 |
output = f'Recording successfully saved! Click `Push` when you are done to send your recordings to the repo.'
|
| 62 |
|
| 63 |
-
|
|
|
|
|
|
|
| 64 |
output = 'Language must be specified!'
|
| 65 |
output_string = "<html> <body> <div class='output' style='color:green; font-size:13px'>"+output+"</div> </body> </html>"
|
| 66 |
return output_string
|
|
@@ -101,6 +104,9 @@ markdown = """# Africa Crowdsource Speech
|
|
| 101 |
### a platform to contribute to your African language by recording your voice"""
|
| 102 |
|
| 103 |
|
|
|
|
|
|
|
|
|
|
| 104 |
# Interface design begins
|
| 105 |
block = gr.Blocks()
|
| 106 |
with block:
|
|
@@ -109,14 +115,22 @@ with block:
|
|
| 109 |
|
| 110 |
with gr.TabItem('Record'):
|
| 111 |
#with gr.Row():
|
| 112 |
-
language = gr.inputs.Dropdown(choices = list(DEFAULT_LANGS.keys()),label="language",default="Choose language")
|
| 113 |
-
text = gr.inputs.Textbox(placeholder='Write your text',label="text to record")
|
| 114 |
-
record = gr.inputs.Audio(source="microphone",label='Record your voice')
|
| 115 |
-
output_result = gr.outputs.HTML()
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
save.click(save_record, inputs=[language,text,record],outputs=output_result)
|
| 122 |
push.click(push_record, inputs=[],outputs=output_result)
|
|
@@ -127,4 +141,4 @@ with block:
|
|
| 127 |
listen.click(display_records,inputs=[],outputs=gr.outputs.HTML() )
|
| 128 |
|
| 129 |
|
| 130 |
-
block.launch(
|
|
|
|
| 37 |
def save_record(language,text,record):
|
| 38 |
# Save text and its corresponding record to flag
|
| 39 |
|
| 40 |
+
if language!=None and language!='Choose language' and record is not None:
|
| 41 |
lang_id = DEFAULT_LANGS[language]
|
| 42 |
text =text.strip()
|
| 43 |
|
| 44 |
# Write audio to file
|
| 45 |
audio_output_filename = os.path.join(AUDIO_PATH,f'{len(os.listdir(AUDIO_PATH))}.wav')
|
| 46 |
+
import pdb; pdb.set_trace()
|
| 47 |
wavf.write(audio_output_filename,record[0],record[1])
|
| 48 |
|
| 49 |
if not os.path.exists(DATA_FILE):
|
|
|
|
| 61 |
|
| 62 |
output = f'Recording successfully saved! Click `Push` when you are done to send your recordings to the repo.'
|
| 63 |
|
| 64 |
+
if record is None:
|
| 65 |
+
output="No recording found!"
|
| 66 |
+
if language is None or language=='Choose language':
|
| 67 |
output = 'Language must be specified!'
|
| 68 |
output_string = "<html> <body> <div class='output' style='color:green; font-size:13px'>"+output+"</div> </body> </html>"
|
| 69 |
return output_string
|
|
|
|
| 104 |
### a platform to contribute to your African language by recording your voice"""
|
| 105 |
|
| 106 |
|
| 107 |
+
GENDER = ['Choose Gender','Male','Female','Other','Prefer not to say']
|
| 108 |
+
NUMBERS = [i for i in range(21)]
|
| 109 |
+
|
| 110 |
# Interface design begins
|
| 111 |
block = gr.Blocks()
|
| 112 |
with block:
|
|
|
|
| 115 |
|
| 116 |
with gr.TabItem('Record'):
|
| 117 |
#with gr.Row():
|
| 118 |
+
language = gr.inputs.Dropdown(choices = list(DEFAULT_LANGS.keys()),label="Choose language",default="Choose language")
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
+
with gr.Row():
|
| 121 |
+
name = gr.inputs.Textbox(placeholder='e.g John Doe',label="Your name")
|
| 122 |
+
gender = gr.inputs.Dropdown(choices=GENDER, type="value", default=None, label="Gender")
|
| 123 |
+
accent = gr.inputs.Textbox(label="Accent (if any)")
|
| 124 |
+
|
| 125 |
+
number = gr.inputs.Radio(choices=NUMBERS, type="value", default=None, label="Choose your number")
|
| 126 |
+
with gr.Row():
|
| 127 |
+
text = gr.inputs.Textbox(placeholder='e.g `one` is `otu` in Igbo or `ọkan` in Yoruba',label="Number in your language")
|
| 128 |
+
record = gr.inputs.Audio(source="microphone",label='Record your voice')
|
| 129 |
+
|
| 130 |
+
output_result = gr.outputs.HTML()
|
| 131 |
+
with gr.Row():
|
| 132 |
+
save = gr.Button("Save")
|
| 133 |
+
push = gr.Button('Submit')
|
| 134 |
|
| 135 |
save.click(save_record, inputs=[language,text,record],outputs=output_result)
|
| 136 |
push.click(push_record, inputs=[],outputs=output_result)
|
|
|
|
| 141 |
listen.click(display_records,inputs=[],outputs=gr.outputs.HTML() )
|
| 142 |
|
| 143 |
|
| 144 |
+
block.launch()
|
data
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
Subproject commit
|
|
|
|
| 1 |
+
Subproject commit c657eb8a248c1474eaa90dd3d6c4af3d6a31e7c5
|