File size: 1,935 Bytes
a362d69
 
 
d348741
a362d69
 
d348741
a362d69
 
d348741
a362d69
 
d348741
a362d69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbbf27f
a362d69
 
 
 
 
 
 
 
 
 
 
 
 
 
a97af56
a362d69
 
 
 
 
 
 
6f3a3e1
 
 
 
a362d69
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
58
59
60
import gradio as gr
import transmorgrify

eng_to_ipa_tm = transmorgrify.Transmorgrifier()
eng_to_ipa_tm.load( "./examples/phonetic/phonetics_gpu_4000.tm" )

ipa_to_eng_tm = transmorgrify.Transmorgrifier()
ipa_to_eng_tm.load( "./examples/phonetic/reverse_phonetics_gpu_4000.tm")

eng_to_pig_tm = transmorgrify.Transmorgrifier()
eng_to_pig_tm.load( "./examples/piglattin/piglattin_gpu_4000.tm" )

pig_to_eng_tm = transmorgrify.Transmorgrifier()
pig_to_eng_tm.load( "./examples/piglattin/reverse_piglattin_gpu_4000.tm" )


def eng_to_ipa( input ):
    return list(eng_to_ipa_tm.execute( [input] ) )[0]

def ipa_to_eng( input ):
    return list(ipa_to_eng_tm.execute( [input] ) )[0]

def eng_to_pig( input ):
    return list(eng_to_pig_tm.execute( [input] ) )[0]

def pig_to_eng( input ):
    return list(pig_to_eng_tm.execute( [input] ) )[0]

with gr.Blocks() as demo:
    gr.Markdown(
"""
# Sentence Transmorgrifier demo
The following demos have been trained on different tasks.
Select the tab below for a demo.
"""
    )

    with gr.Tab( "IPA" ):
        english_in = gr.Textbox( label="English in" )
        ipa_out = gr.Textbox( label='IPA out')
        gr.Button( value='Transmorgrify' ).click( eng_to_ipa, english_in, ipa_out )

        ipa_in = gr.Textbox( label="IPA in" )
        english_out = gr.Textbox( label='English out')
        gr.Button( value='Transmorgrify' ).click( ipa_to_eng , ipa_in, english_out )

    with gr.Tab( "Pig latin" ):
        english_in = gr.Textbox( label="English in" )
        pig_out = gr.Textbox( label='Pig latin out')
        gr.Button( value='Transmorgrify' ).click( eng_to_pig, english_in, pig_out )

        pig_in = gr.Textbox( label="Pig latin in" )
        english_out = gr.Textbox( label='English out')
        gr.Button( value='Transmorgrify' ).click( pig_to_eng , pig_in, english_out )

    with open( "README.md" ) as readme_in:
        gr.Markdown( readme_in.read() )

demo.launch()