from mixer import Mixer from examples import examples def launch(mixer:Mixer): # Runners def clear(): return "" def mix(sentence_A:str,sentence_B:str,A_ratio:float): return mixer.mix_sentences(sentence_A, sentence_B, A_ratio) # Components from gradio import Blocks, Slider, Markdown, Row, Column, Button, TextArea, Examples with Blocks() as app: Markdown( "# Sentence Mixer\n"\ "Linear combination of the encoder hidden states generates mixed sentences." ) with Row(): with Column(): sentenceA_textarea = TextArea(label="Sentence A", lines=4) sentenceA_clearbutton = Button(value="Clear", size="sm") with Column(): sentenceB_textarea = TextArea(label="Sentence B", lines=4) sentenceB_clearbutton = Button(value="Clear", size="sm") with Row(): Aratio_slider = Slider(label="A Ratio", minimum=0.0, maximum=1.0, value=0.5, step=0.001) mix_button = Button(value="Mix", variant="primary") output_textarea = TextArea(label="Mixed Sentence", lines=2) Examples( examples, inputs=[sentenceA_textarea,sentenceB_textarea,Aratio_slider], outputs=output_textarea ) # Bindings sentenceA_clearbutton.click(clear, inputs=None, outputs=sentenceA_textarea) sentenceB_clearbutton.click(clear, inputs=None, outputs=sentenceB_textarea) mix_button.click( mix, inputs=[sentenceA_textarea,sentenceB_textarea,Aratio_slider], outputs=output_textarea ) app.launch()