File size: 671 Bytes
5900da3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9b43175
6529d39
 
5900da3
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const textGenForm = document.querySelector('.text-gen-form');

const translateText = async (text) => {
    const inferResponse = await fetch(`infer_t5?input=${text}`);
    const inferJson = await inferResponse.json();

    return inferJson.output;
};

textGenForm.addEventListener('submit', async (event) => {
  event.preventDefault();

  const textGenInput = document.getElementById('text-gen-input');
  const textGenParagraph = document.querySelector('.text-gen-output');

  try {
    var text_out = await translateText(textGenInput.value);
    text_out = text_out+"\n"+"s";
    textGenParagraph.textContent = text_out;
  } catch (err) {
    console.error(err);
  }
});