File size: 1,027 Bytes
1092f22
 
d6170b8
1ec6226
d6170b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1ec6226
1092f22
d6170b8
1092f22
 
d6170b8
 
 
1092f22
1ec6226
1092f22
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
import gradio as gr
import requests
import json

def get_spell_correction(input_text):
    response = requests.post(
        "https://api.respell.ai/v1/run",
        headers={
            "Authorization": "Bearer 260cee54-6d54-48ba-92e8-bf641b5f4805",
            "Accept": "application/json",
            "Content-Type": "application/json"
        },
        data=json.dumps({
            "spellId": "1th5Ic7ZnMmZXBtZCfR7-",
            # This field can be omitted to run the latest published version
            "spellVersionId": "-NTOo8UsyhC-3g52p7ExZ",
            # Fill in a value for your dynamic input block
            "inputs": {
                "pregunta": input_text,
            }
        }),
    )
    return response.json()["results"]["corrections"]["pregunta"]["text"]

iface = gr.Interface(
    fn=get_spell_correction,
    inputs="text",
    outputs="text",
    title="Respell Spell Checker",
    description="Correct spelling using the Respell API.",
    example="Enter your text here...",
)

iface.launch()