-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.html
76 lines (58 loc) · 3.22 KB
/
test.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button id="summarize_button">Test Summarize</button>
<button id="text_to_speech_button">Test Text to Speech</button>
<div id="whisper-block">
<input type="file" id="whisper-file" accept="audio/*" />
<button id="speech-to-text-button">Test Speech to Text</button>
</div>
<div id="ocr-block">
<input type="file" id="ocr-file" accept="image/*" />
<button id="image-to-text-button">Test Image to Text</button>
</div>
<div id="image-classify-block">
<input type="file" id="image-classify-file" accept="image/*" />
<button id="image-classify-button">Test Image Classification</button>
</div>
<script type="module">
document.querySelector("#summarize_button").addEventListener("click", async () => {
const { summarize } = await import("/dist/index.js");
const text = "JavaScript is a versatile and widely-used programming language primarily known for its role in front-end web development. It enables developers to create interactive and dynamic content on websites, such as responding to user inputs, animating elements, and updating content without requiring a page reload. JavaScript can be run in the browser, which makes it essential for creating modern web applications, but it is also used on the server side with environments like Node.js. Its flexibility, combined with a vast ecosystem of libraries and frameworks, makes JavaScript a fundamental tool for building both simple websites and complex web applications.";
const summary = await summarize(text);
console.log(summary);
});
document.querySelector("#text_to_speech_button").addEventListener("click", async () => {
const { textToSpeech } = await import("/dist/index.js");
const text = "Hello, world!";
const audio = await textToSpeech(text);
console.log(audio);
});
document.querySelector("#speech-to-text-button").addEventListener("click", async () => {
const { transcribeAudioFile } = await import("/dist/index.js");
const file = document.querySelector("#whisper-file").files[0];
const text = await transcribeAudioFile(file);
console.log(text);
});
document.querySelector("#image-to-text-button").addEventListener("click", async () => {
const { ocr } = await import("/dist/index.js");
const file = document.querySelector("#ocr-file").files[0];
const text = await ocr(URL.createObjectURL(file));
console.log(text);
URL.revokeObjectURL(file);
});
document.querySelector("#image-classify-button").addEventListener("click", async () => {
const { classifyImage } = await import("/dist/index.js");
const file = document.querySelector("#image-classify-file").files[0];
const text = await classifyImage(URL.createObjectURL(file));
console.log(text);
URL.revokeObjectURL(file);
});
</script>
</body>
</html>