Comments (4)
Service worker
<script src="sw-transformers.js"></script>
// sw-transformers.js
if (self.document) {
// main script
navigator.serviceWorker?.register("sw-transformers.js");
} else {
// service worker script
self.addEventListener("fetch", (event) => {
event.respondWith(
(async () => {
let request, cache, response;
request = event.request;
cache = await caches.open("transformers-cache");
response = await cache.match(request);
if (response) return response;
response = await fetch(request);
if (response.status === 200 && !request.url.match(/onnx$|json$/)) {
// cache files other than onnx and json (cached by transformers.js)
cache.put(request, response.clone());
}
return response;
})(),
);
});
}
from transformers.js.
Clear browser cache
async function clearBrowserCache() {
return await caches.delete('transformers-cache');
}
from transformers.js.
Node.js progress callback
const { pipeline } = await import('@xenova/transformers');
function progress_callback(args) {
if (args.status != 'progress') return;
let n = Math.floor(args.progress / 5);
let str = '\r[' + '#'.repeat(n) + '.'.repeat(20 - n) + '] ' + args.file + (n == 20 ? '\n' : '');
process.stdout.write(str);
}
let pipe = await pipeline('text-to-speech', 'Xenova/mms-tts-eng', {progress_callback});
from transformers.js.
Web progress callback
<div>
<progress id="progress" value="0" max="100"></progress>
<label for="progress">0</label>
</div>
function progress_callback(args) {
if (args.status != 'progress') return;
let elm = document.getElementById('progress')
if(!elm) return
elm.value = args.progress
if(args.progress == 100 && elm.labels[0]) elm.labels[0].innerHTML = +elm.labels[0].innerHTML + 1
}
let pipe = await pipeline('text-to-speech', 'Xenova/mms-tts-eng', {progress_callback});
from transformers.js.
Related Issues (20)
- V3 audio transcription: aud.subarray is not a function HOT 8
- range error: array buffer allocation failed <- how to catch this error?
- transformers@latest: Unsupported model IR version: 9, max supported IR version: 8 HOT 1
- Support nomic-ai/nomic-embed-vision-v1.5 HOT 1
- AutoModel.from_pretrained - Which model is loaded HOT 1
- The scripts/convert.py script fails for a few reasons HOT 1
- RAGatouille/Colbert support
- Result is wrong when decoding tokens one by one HOT 1
- How do you delete a downloaded model? HOT 2
- Support for Both Word-Level and Sentence-Level Timestamps in ASR Decoding
- Segmentation fault while converting Bert-base-uncased with README command HOT 2
- Can't run depth-anything-v2 HOT 1
- Support for react-native
- JavaScript code completion model
- [Severe] Memory leak issue under WebGPU Whisper transcribe pipeline
- 4bit ONNX models support HOT 1
- how to retain spiece token markers HOT 2
- No loader is configured for ".node" files
- musicgen example run error on lastest v3
- compat with transformers >= 4.40 and tokenizers >= 0.19 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transformers.js.