-
Notifications
You must be signed in to change notification settings - Fork 1
/
music-generator.html
33 lines (29 loc) · 1.1 KB
/
music-generator.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Transformers.js Example</title>
</head>
<body>
<h1>Transformers.js Example</h1>
<div id="result"></div>
<script type="module">
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2';
// Asynchronous function to load and use the pipeline
(async () => {
try {
// Load the sentiment-analysis pipeline
const sentimentAnalysis = await pipeline('sentiment-analysis');
// Analyze a sample text
const result = await sentimentAnalysis('I love Transformers.js!');
// Display the result
document.getElementById('result').innerText = JSON.stringify(result, null, 2);
} catch (error) {
console.error('Error loading pipeline:', error);
document.getElementById('result').innerText = 'Error loading the pipeline!';
}
})();
</script>
</body>
</html>