Spaces:
Build error
Build error
app.py with blocks
Browse files
app.py
CHANGED
@@ -5,12 +5,19 @@ import gradio as gr
|
|
5 |
#HF_TOKEN = os.environ.get("HF_TOKEN")
|
6 |
#print("is none?", HF_TOKEN is None)
|
7 |
|
|
|
|
|
|
|
8 |
def get_record(language,text,record):
|
9 |
# Save text and its corresponding record to flag
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
14 |
return output_string
|
15 |
|
16 |
title = 'African Crowdsource Speech'
|
@@ -18,7 +25,6 @@ description = 'A platform to contribute to your African language by recording yo
|
|
18 |
|
19 |
markdown = """African Crowdsource Speech: a platform to contribute to your African language by recording your voice"""
|
20 |
|
21 |
-
# Get a dropdown of all African languages
|
22 |
|
23 |
# Interface design begins
|
24 |
block = gr.Blocks()
|
@@ -27,8 +33,8 @@ with block:
|
|
27 |
|
28 |
#with gr.Tab('version1'):
|
29 |
#with gr.Row():
|
30 |
-
language = gr.inputs.
|
31 |
-
text = gr.inputs.Textbox(placeholder='Write your text')
|
32 |
record = gr.inputs.Audio(source="microphone",label='Record your voice')
|
33 |
output_result = gr.outputs.HTML()
|
34 |
|
5 |
#HF_TOKEN = os.environ.get("HF_TOKEN")
|
6 |
#print("is none?", HF_TOKEN is None)
|
7 |
|
8 |
+
# Get a dropdown of all African languages
|
9 |
+
DEFAULT_LANGS = {'Igbo':'ibo','Yoruba':'yor','Hausa':'hau'}
|
10 |
+
|
11 |
def get_record(language,text,record):
|
12 |
# Save text and its corresponding record to flag
|
13 |
+
if language!=None and language!='Choose language':
|
14 |
+
lang_id = DEFAULT_LANGS[language]
|
15 |
+
text =text.strip()
|
16 |
+
output = f'Recording successfully saved to dataset! Thank You.'+'\n'+f'(Text: <i>{text}</i>, language: {lang_id}).'
|
17 |
+
|
18 |
+
else:
|
19 |
+
output = 'Language must be specified!'
|
20 |
+
output_string = "<html> <body> <div class='output' style='color:green; font-size:13px'>"+output+"</div> </body> </html>"
|
21 |
return output_string
|
22 |
|
23 |
title = 'African Crowdsource Speech'
|
25 |
|
26 |
markdown = """African Crowdsource Speech: a platform to contribute to your African language by recording your voice"""
|
27 |
|
|
|
28 |
|
29 |
# Interface design begins
|
30 |
block = gr.Blocks()
|
33 |
|
34 |
#with gr.Tab('version1'):
|
35 |
#with gr.Row():
|
36 |
+
language = gr.inputs.Dropdown(choices = list(DEFAULT_LANGS.keys()),label="language",default="Choose language")
|
37 |
+
text = gr.inputs.Textbox(placeholder='Write your text',label="text to record")
|
38 |
record = gr.inputs.Audio(source="microphone",label='Record your voice')
|
39 |
output_result = gr.outputs.HTML()
|
40 |
|