Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,83 +1,16 @@
|
|
1 |
import os
|
2 |
-
import warnings
|
3 |
-
import gradio as gr
|
4 |
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
HF_TOKEN = os.getenv('HW_TOKEN')
|
14 |
-
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "save_audio")
|
15 |
-
|
16 |
-
|
17 |
-
cur_line=0
|
18 |
-
|
19 |
-
def readFile():
|
20 |
-
f=open('prompt.txt')
|
21 |
-
line_num=0
|
22 |
-
lines=f.readlines()
|
23 |
-
line_num = len(lines)
|
24 |
-
return line_num,lines
|
25 |
-
|
26 |
-
totlines,file_content=readFile()
|
27 |
-
|
28 |
-
callback = gr.CSVLogger()
|
29 |
-
|
30 |
-
def readPromt():
|
31 |
-
global cur_line
|
32 |
-
cur_line+=1
|
33 |
-
global file_content
|
34 |
-
print (cur_line)
|
35 |
-
return file_content[cur_line]
|
36 |
-
|
37 |
-
def readNext():
|
38 |
-
|
39 |
-
global totlines
|
40 |
-
print(totlines)
|
41 |
-
global cur_line
|
42 |
-
if cur_line<totlines-1:
|
43 |
-
cur_line+=1
|
44 |
-
global file_content
|
45 |
-
print (cur_line)
|
46 |
-
return [file_content[cur_line],None]
|
47 |
-
|
48 |
-
def readPrevious():
|
49 |
-
global cur_line
|
50 |
-
if cur_line>=0:
|
51 |
-
cur_line-=1
|
52 |
-
#cur_line=current_line
|
53 |
-
global file_content
|
54 |
-
print (cur_line)
|
55 |
-
return [file_content[cur_line],None]
|
56 |
-
|
57 |
-
demo = gr.Blocks()
|
58 |
-
|
59 |
-
with demo:
|
60 |
-
#dr=gr.Dropdown(["Hindi","Odiya"],value="Odiya",label="Select Language")
|
61 |
-
#audio_file = gr.Audio(sources=["microphone","upload"],type="filepath")
|
62 |
-
text = gr.Textbox(readPromt())
|
63 |
-
upfile = gr.Audio(
|
64 |
-
sources=["microphone","upload"], type="filepath", label="Record"
|
65 |
-
)
|
66 |
-
#upfile = gr.inputs.Audio(source="upload", type="filepath", label="Upload")
|
67 |
-
|
68 |
-
with gr.Row():
|
69 |
-
b1 = gr.Button("Save")
|
70 |
-
b2 = gr.Button("Next")
|
71 |
-
b3 = gr.Button("Previous")
|
72 |
-
#b4=gr.Button("Clear")
|
73 |
-
b2.click(readNext,inputs=None,outputs=[text,upfile])
|
74 |
-
b3.click(readPrevious,inputs=None,outputs=[text,upfile])
|
75 |
-
#b4.click(lambda: None, outputs=upfile)
|
76 |
-
# b1.click(sel_lng, inputs=[dr,mic,upfile], outputs=text)
|
77 |
-
#b2.click(text_to_sentiment, inputs=text, outputs=label)
|
78 |
-
#callback.setup([text, upfile], "flagged_data_points")
|
79 |
-
#callback.setup([text, upfile], hf_writer)
|
80 |
-
#b1.click(lambda *args: callback.flag(args), [text, upfile], None, preprocess=False)
|
81 |
flagging_callback=hf_writer
|
82 |
-
|
83 |
-
|
|
|
|
1 |
import os
|
|
|
|
|
2 |
|
3 |
+
HF_TOKEN = os.getenv('HF_TOKEN')
|
4 |
+
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "crowdsourced-calculator-demo")
|
5 |
|
6 |
+
iface = gr.Interface(
|
7 |
+
calculator,
|
8 |
+
["number", gr.Radio(["add", "subtract", "multiply", "divide"]), "number"],
|
9 |
+
"number",
|
10 |
+
description="Check out the crowd-sourced dataset at: [https://huggingface.co/datasets/aliabd/crowdsourced-calculator-demo](https://huggingface.co/datasets/aliabd/crowdsourced-calculator-demo)",
|
11 |
+
allow_flagging="manual",
|
12 |
+
flagging_options=["wrong sign", "off by one", "other"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
flagging_callback=hf_writer
|
14 |
+
)
|
15 |
+
|
16 |
+
iface.launch()
|