Platform
Resources
Pricing
Sign in
Get started
John Alexis Guerra Gómez
I love to build dataviz for insight discovery. I also love to put technology to the service of humanity
Workspace
Fork
Public
Machine Learning
By
John Alexis Guerra Gómez
Edited
Apr 8
Machine Learning
Transformers.js Text to Speech
Transformers.js Sentiment Analysis
Insert cell
Insert cell
viewof
text
=
Inputs
.
text
(
{
submit
:
false
,
value
:
"Quite an impressive demo"
}
)
Insert cell
${sentiment[0].label=== "POSITIVE" ? "✅" : "❌"} ${sentiment[0].score.toFixed(2)}
Insert cell
sentiment
=
pipeSentiment
(
text
)
Insert cell
pipeSentiment
=
transformersJS
.
pipeline
(
"sentiment-analysis"
,
"Xenova/distilbert-base-uncased-finetuned-sst-2-english"
,
{
device
:
"webgpu"
,
// use to use the GPU
// dtype: "q4" // use to save bandwidth
}
)
Insert cell
transformersJS
=
import
(
'https://unpkg.com/@huggingface/transformers@3.4.2/dist/transformers.min.js?module'
)
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
text
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sentiment
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
pipeSentiment
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
transformersJS
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML