File tree Expand file tree Collapse file tree
content/workshops/ai/translate-hugging-face Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,8 @@ Crowd-sourced resources:
5252
5353https://huggingface.co/spaces/gradio-tests/english_to_spanish
5454
55+ ## Try it!
56+
5557<iframe
5658 src="https://gradio-tests-english-to-spanish.hf.space"
5759 frameborder="0"
@@ -79,3 +81,27 @@ Select Javascript.
7981
8082
8183{{% /section %}}
84+
85+ ---
86+
87+ ### Javascript call to the API
88+
89+ ``` js
90+ $ cat index .js
91+ import { client } from " @gradio/client" ;
92+
93+ const app = await client (" https://gradio-tests-english-to-spanish.hf.space/" );
94+ const result = await app .predict (" /predict" , [
95+ " Howdy!" , // string in 'text' Textbox component
96+ ]);
97+
98+ console .log (result .data );
99+ ```
100+
101+ ``` bash
102+ $ npm i -D @gradio/client
103+ $ node index.js
104+ [ ' ¡Hola!' ]
105+ ```
106+
107+ See code here: https://github.com/grizzlyhacks/workshop-hugging-face-translate
You can’t perform that action at this time.
0 commit comments