Spaces:
Sleeping
Sleeping
File size: 1,315 Bytes
7fdea9e 3a48ae1 7fdea9e af7e87c 7fdea9e af7e87c 7fdea9e af7e87c 7fdea9e af7e87c |
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 |
import gradio as gr
#from transformers import pipeline
#pipe = pipeline("translation", model="t5-base")
get_local_storage = """
function() {
globalThis.setStorage = (key, value)=>{
localStorage.setItem(key, JSON.stringify(value))
}
globalThis.getStorage = (key, value)=>{
return JSON.parse(localStorage.getItem(key))
}
const text_input = getStorage('text_input')
return text_input;
}
"""
def translate(text):
return text
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
english = gr.Textbox(label="English text")
text_input = gr.Text(label="Input va allá")
text_input.change(None, text_input, None, _js="(v)=>{ setStorage('text_input',v) }")
translate_btn = gr.Button(value="Translate")
with gr.Column():
german = gr.Textbox(label="German Text")
translate_btn.click(translate, inputs=english, outputs=german)
examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."],
inputs=[english])
demo.load(
None,
inputs=None,
outputs=text_input,
_js=get_local_storage,
)
demo.launch(debug=True)
|