File size: 1,831 Bytes
45585f3
 
 
 
1ce34be
 
45585f3
 
 
 
 
c320029
50064ee
ef70edd
45585f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cedda65
 
 
 
 
 
 
ef70edd
badcb78
 
227b260
50064ee
45585f3
cedda65
 
 
 
 
 
 
 
 
 
 
 
 
227b260
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import gradio as gr


#HF_TOKEN = os.environ.get("HF_TOKEN")
#print("is none?", HF_TOKEN is None)

def get_record(language,text,record):
    # Save text and its corresponding record to flag
    
    text =text.strip()
    output_string = "<html> <body> <div class='output'>"+f'Record for text {text} successfully saved to dataset! Thank You.'+"</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
"""

# Get a dropdown of all African languages

# Interface design begins
block = gr.Blocks()
with block:
    gr.Markdown(markdown)

    with gr.Tab('version1'):
        #with gr.Row():
        language = gr.inputs.Textbox(placeholder='Choose your language')
        text = gr.inputs.Textbox(placeholder='Write your text')
        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)

    with gr.Tab('version2'):
        gr.Interface(fn=get_record,
                    inputs=[gr.inputs.Textbox(placeholder='Choose your language'),
                    gr.inputs.Textbox(placeholder='Write your text'),
                     gr.inputs.Audio(source="microphone",label='Record your voice')
                            ],
                    outputs = gr.outputs.HTML(),
                    title=title,
                    description=description,
                    enable_queue=True,
                    theme='huggingface'
                            ).launch()

block.launch(enable_queue=True)