Spaces:
Build error
Build error
import os | |
import gradio as gr | |
#HF_TOKEN = os.environ.get("HF_TOKEN") | |
#print("is none?", HF_TOKEN is None) | |
# Get a dropdown of all African languages | |
DEFAULT_LANGS = {'Igbo':'ibo','Yoruba':'yor','Hausa':'hau'} | |
def get_record(language,text,record): | |
# Save text and its corresponding record to flag | |
if language!=None and language!='Choose language': | |
lang_id = DEFAULT_LANGS[language] | |
text =text.strip() | |
output = f'Recording successfully saved to dataset! Thank You.'+'\n'+f'(Text: <i>{text}</i>, language: {lang_id}).' | |
else: | |
output = 'Language must be specified!' | |
output_string = "<html> <body> <div class='output' style='color:green; font-size:13px'>"+output+"</div> </body> </html>" | |
return output_string | |
title = 'African Crowdsource Speech' | |
description = 'A platform to contribute to your African language by recording your voice' | |
markdown = """African Crowdsource Speech: a platform to contribute to your African language by recording your voice""" | |
# Interface design begins | |
block = gr.Blocks() | |
with block: | |
gr.Markdown(markdown) | |
#with gr.Tab('version1'): | |
#with gr.Row(): | |
language = gr.inputs.Dropdown(choices = list(DEFAULT_LANGS.keys()),label="language",default="Choose language") | |
text = gr.inputs.Textbox(placeholder='Write your text',label="text to record") | |
record = gr.inputs.Audio(source="microphone",label='Record your voice') | |
output_result = gr.outputs.HTML() | |
save = gr.Button("Save") | |
save.click(get_record, inputs=[language,text,record],outputs=output_result) | |
block.launch(enable_queue=True) |