- 浏览: 1476358 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (691)
- linux (207)
- shell (33)
- java (42)
- 其他 (22)
- javascript (33)
- cloud (16)
- python (33)
- c (48)
- sql (12)
- 工具 (6)
- 缓存 (16)
- ubuntu (7)
- perl (3)
- lua (2)
- 超级有用 (2)
- 服务器 (2)
- mac (22)
- nginx (34)
- php (2)
- 内核 (2)
- gdb (13)
- ICTCLAS (2)
- mac android (0)
- unix (1)
- android (1)
- vim (1)
- epoll (1)
- ios (21)
- mysql (3)
- systemtap (1)
- 算法 (2)
- 汇编 (2)
- arm (3)
- 我的数据结构 (8)
- websocket (12)
- hadoop (5)
- thrift (2)
- hbase (1)
- graphviz (1)
- redis (1)
- raspberry (2)
- qemu (31)
- opencv (4)
- socket (1)
- opengl (1)
- ibeacons (1)
- emacs (6)
- openstack (24)
- docker (1)
- webrtc (11)
- angularjs (2)
- neutron (23)
- jslinux (18)
- 网络 (13)
- tap (9)
- tensorflow (8)
- nlu (4)
- asm.js (5)
- sip (3)
- xl2tp (5)
- conda (1)
- emscripten (6)
- ffmpeg (10)
- srt (1)
- wasm (5)
- bert (3)
- kaldi (4)
- 知识图谱 (1)
最新评论
-
wahahachuang8:
我喜欢代码简洁易读,服务稳定的推送服务,前段时间研究了一下go ...
websocket的helloworld -
q114687576:
http://www.blue-zero.com/WebSoc ...
websocket的helloworld -
zhaoyanzimm:
感谢您的分享,给我提供了很大的帮助,在使用过程中发现了一个问题 ...
nginx的helloworld模块的helloworld -
haoningabc:
leebyte 写道太NB了,期待早日用上Killinux!么 ...
qemu+emacs+gdb调试内核 -
leebyte:
太NB了,期待早日用上Killinux!
qemu+emacs+gdb调试内核
kaldi-wasm/src/workers/asrWorker.js
resamplerWorker.js
import JSZip from 'jszip'; import kaldiJS from '../computations/kaldiJS'; import kaldiWasm from '../computations/kaldiJS.wasm'; import KaldiConfigParser from '../utils/kaldiConfigParser'; const kaldiModule = kaldiJS({ locateFile(path) { if (path.endsWith('.wasm')){ console.log("hao-asrWorer.js---kaldiJS:"+path); return kaldiWasm; } // if (path.endsWith('.wasm')) return kaldiJS; return path; }, }); const MODEL_STORE = { NAME: 'models', KEY_PATH: 'language', }; let asr = null; let parser = null; function mkdirExistOK(fileSystem, path) { console.log("hao:asrWorker.js---mkdirExistOK----->path:" +path) // console.log(fileSystem); try { //fileSystem.mkdir(path); fileSystem.mkdir(path); } catch (e) { console.log("hao--mkdirExistOK--error..$$$$$$$$$$$$$$$$$$$$"); if (e.code !== 'EEXIST') throw e; } } function initEMFS(fileSystem, modelName) { console.log("hao-asrWorker---initEMFS--fileSystem:"); console.log(fileSystem); mkdirExistOK(fileSystem, MODEL_STORE.NAME); console.log("hao-asrWorker---initEMFS--MODEL_STORE.NAME:"+MODEL_STORE.NAME); fileSystem.mount(fileSystem.filesystems.IDBFS, {}, MODEL_STORE.NAME); fileSystem.chdir(MODEL_STORE.NAME); fileSystem.mkdir(modelName); fileSystem.chdir(modelName); console.log("hao-asrWorker---initEMFS--over."); } async function unzip(zipfile) { // console.log("hao-asrWorker---unzip--:"); // console.log(zipfile); const zip = new JSZip(); const unzipped = await zip.loadAsync(zipfile); return unzipped; } function dirname(path) { const dirs = path.match(/.*\//); if (dirs === null) return ''; // without trailing '/' return dirs[0].slice(0, dirs[0].length - 1); } function mkdirp(fileSystem, path) { console.log("hao-asrWorker-----mkdirp--path:"+path); console.log(fileSystem); const dirBoundary = '/'; const startIndex = path[0] === dirBoundary ? 1 : 0; for (let i = startIndex; i < path.length; i += 1) { if (path[i] === dirBoundary) mkdirExistOK(fileSystem, path.slice(0, i)); } mkdirExistOK(fileSystem, path); } async function writeToFileSystem(fileSystem, path, fileObj) { console.log("asrWorker.js---writeToFileSystem---fileSystem:"+path); console.log(fileSystem); const content = await fileObj.async('arraybuffer'); //console.log("content:"+content); try { fileSystem.writeFile(path, new Uint8Array(content)); //fileSystem.writeFile(path, new Uint8Array(content),function(err){ // console.log("writefile-----error:"+err); //}); // console.log("asrWorker.js---writeToFileSystem---writeFile----over.path:"+fileSystem.cwd()+"/"+path); // console.log("asrWorker.js---writeToFileSystem---isDir----models:"+fileSystem.isDir("/models")); // console.log("asrWorker.js---writeToFileSystem---isDir:::"+fileSystem.isDir(fileSystem.cwd())); // console.log("asrWorker.js---writeToFileSystem---final.mdl---isFile:"+fileSystem.isFile("final.mdl")); console.log("asrWorker.js---writeToFileSystem---end----------"); return; } catch (e) { console.log("hao---error:-->>>>>>>>>>>>>>>>>>>>>>>writeToFileSystem......>path--->"+path); console.log(e); console.log(e.code); if (e.code === 'ENOENT') { //if (e.errno == 44) { const dirName = dirname(path); console.log("hao---error:-->dirname--writeToFileSystem......>"+dirName); mkdirp(fileSystem, dirName); // eslint-disable-next-line consistent-return return writeToFileSystem(fileSystem, path, fileObj); } throw e; } } var thisModule; async function loadToFS(modelName, zip) { // console.log("hao-asrWorker---loadToFS--begin----kaldiModule:"); // console.log(kaldiModule); console.log("hao-asrWorker---loadToFS---unzip begin") const unzipped = await unzip(zip); console.log("hao-asrWorker---loadToFS--unzip over...."); await kaldiModule.then( function(result){ console.log("hao---hao-asrWorker---loadToFS----kaldiModule.then:") console.log(result.FS); thisModule=result; initEMFS(thisModule.FS, modelName); }); //initEMFS(kaldiModule.FS, modelName); //const unzipped = await unzip(zip); //const unzipped = unzip(zip); // hack to wait for model saving on Emscripten fileSystem // unzipped.forEach does not allow to wait for end of async calls const files = Object.keys(unzipped.files); await Promise.all( files.map(async (file) => { console.log("asrWorker----loadToFS---Promise.all...files.map--->"+file); const content = unzipped.file(file); if (content !== null) { //await writeToFileSystem(kaldiModule.FS, content.name, content); //await writeToFileSystem(thisModule.FS, content.name, content); // console.log(" hao -----asrWorker----content.name--->"+content.name); const cwd = thisModule.FS.cwd(); // console.log(" hao------asrWorker-----cwd------>"+cwd); await writeToFileSystem(thisModule.FS, content.name, content); } }) ); // } // ); // .then( // function(endResult){ // asr = startASR(endResult); // // asr = startASR(); // } // ); // asr = startASR(thisModule); console.log("asrWorker----loadToFS---end-----------------------<"); return true; } /* * Assumes that we are in the directory with the requested model */ //function startASR() { // console.log("hao-asrWorker---startASR"); // parser = new KaldiConfigParser(kaldiModule.FS, kaldiModule.FS.cwd()); // const args = parser.createArgs(); // const cppArgs = args.reduce((wasmArgs, arg) => { // wasmArgs.push_back(arg); // return wasmArgs; // }, new kaldiModule.StringList()); // return new kaldiModule.OnlineASR(cppArgs); //} //function startASR(asrModule) { function startASR() { console.log("hao-asrWorker---startASR---------->thisModule.FS:"); console.log(thisModule.FS); //parser = new KaldiConfigParser(kaldiModule.FS, kaldiModule.FS.cwd()); parser = new KaldiConfigParser(thisModule.FS, thisModule.FS.cwd()); console.log("hao-asrWorker---startASR--------------------------> cwd"); const args = parser.createArgs(); const cppArgs = args.reduce((wasmArgs, arg) => { wasmArgs.push_back(arg); return wasmArgs; }, //new kaldiModule.StringList()); new thisModule.StringList()); //return new kaldiModule.OnlineASR(cppArgs); return new thisModule.OnlineASR(cppArgs); } const helper = { async init(msg) { console.log("hao-asrWoker---init:"+msg+",msg:"); console.log(msg); await loadToFS(msg.data.modelName, msg.data.zip); asr = startASR(); //asr = startASR(thisModule); }, async process(msg) { console.log("hao--->asrWorker--->process---msg:"); console.log(msg); if (asr === null) throw new Error('ASR not ready'); const asrOutput = asr.processBuffer(msg.data.pcm);//pcm undefined console.log("hao--->asrWorker--->process:"+asrOutput); if (asrOutput === ''){ console.log("hao:asrWorker.js ##############error this will null!!!!!!"); return null; } return { isFinal: asrOutput.endsWith('\n'), text: asrOutput.trim(), }; }, async samplerate() { console.log("hao--->asrWorker---->samplerate:"); console.log("parser:"); console.log(parser); if (parser === null) throw new Error('ASR not ready'); console.log(parser.getSampleRate()); return parser.getSampleRate(); }, async reset() { if (asr === null) throw new Error('ASR not ready'); const asrOutput = asr.reset(); const result = { isFinal: asrOutput.endsWith('\n'), text: asrOutput.trim(), }; return result; }, async terminate() { if (asr !== null) asr.delete(); asr = null; }, }; onmessage = (msg) => { const { command } = msg.data; const response = { command, ok: true }; if (command in helper) { helper[command](msg) .then((value) => { response.value = value; }) .catch((e) => { response.ok = false; response.value = e; }) .finally(() => { postMessage(response); }); } else { response.ok = false; response.value = new Error(`Unknown command '${command}'`); postMessage(response); } };
resamplerWorker.js
/* eslint-disable no-restricted-globals */ import resampleJS from '../computations/resampleTo16bint'; import resampleWasm from '../computations/resampleTo16bint.wasm'; let resample = () => {}; let outputInputSampleRateRatio = 1 / 3; /* Webpack renames resources which makes the locateFile function inside resampleJS break. The function below replaces locateFile so as to give the right name when loading the wasm binary. */ const resampleMod = resampleJS({ locateFile(path) { console.log("hao---------->resamplerWorker.js----------->locateFile resampleMod--->>>>>>"); if (path.endsWith('.wasm')) return resampleWasm; return path; }, }); var thisresampleMod; const helper = { //setConversionRatio(msg) { async setConversionRatio(msg) { await resampleMod.then( function(result){ console.log("hao--->>>>>resamplerWorker.js----thisresampleMod.then>>>>>>") thisresampleMod=result; thisresampleMod.init(); // resample = resampleMod.resampleTo16bint; resample = thisresampleMod.resampleTo16bint; //initEMFS(thisModule.FS, modelName); } ); console.log("hao---------->resamplerWorker.js----------->helper-->setConversionRatio msg:"); console.log(msg); outputInputSampleRateRatio = msg.data.conversionRatio; return outputInputSampleRateRatio; }, async resample(msg) { console.log("hao---------->resamplerWorker.js----------->helper-->resample ,msg:"); console.log(msg); return resample(msg.data.buffer, outputInputSampleRateRatio); }, async reset() { // resampleMod.reset(); thisresampleMod.reset(); return ''; }, async terminate() { console.log("hao---------->resamplerWorker.js----------->helper-->terminate >>"); //resampleMod.terminate(); thisresampleMod.terminate(); close(); return ''; }, }; onmessage = (msg) => { const { command } = msg.data; const response = { command, ok: true }; if (command in helper) { helper[command](msg) .then((value) => { response.value = value; }) .catch((e) => { response.ok = false; response.value = e; }) .finally(() => { postMessage(response); }); } else { response.ok = false; response.value = new Error(`Unknown command '${command}'`); postMessage(response); } // if (command in helper){ // console.log("hao---------->resamplerWorker.js--->onmessage command:"+command) // response.value = helper[command](msg); // } // else { // response.ok = false; // response.value = new Error(`Unknown command '${command}'`); // } // postMessage(response); }; //resampleMod.onRuntimeInitialized = () => { // console.log("hao---->resamplerWorker.js-->>>resampleMod.onRuntimeInitialized"); // resampleMod.init(); // resample = resampleMod.resampleTo16bint; //};
发表评论
-
wasm调试c
2021-03-14 22:21 1128[img][/img]在浏览器里调试c,关键就是emcc的时候 ... -
kaidi-wasm学习笔记(三)一些编译的坑
2021-03-01 18:16 12341.需要的包: 把kaldi和 clapack-wasm ... -
kaidi-wasm学习笔记(一)的两个重要文件
2021-02-08 20:18 409最近在看kaldi-wasm 两个重要文件备份一下,总结以后再 ... -
kaldi在mac下基本使用
2020-11-23 22:58 558############ kaldi安装: 通用的安装参考ht ... -
wasm工具
2020-06-14 03:04 674npm install -g cnpm --registr ...
相关推荐
凯迪(Kaidi Cao)*,玛丽亚(MariaBrbić)*,尤里(Jure Leskovec) 此存储库包含COMET算法的PyTorch中的参考源代码。 COMET是一种元学习方法,可沿人类可理解的概念维度学习可概括的表示形式。 有关更多详细信息...
在文件"kaidi0415"中,可能包含了该轻应用的源代码、样式文件、图片资源、配置文件等,开发者可以通过分析这些文件来学习和理解如何构建一个完整的HTML5轻应用。为了进一步了解凯迪拉克HTML5轻应用的实现细节,需要...
例如,在 http://www.sz-kaidi.com/product_show.asp?id=997 中,攻击者可以 inject 恶意 SQL 代码 and 1=1 和 and 1=2 来判断是否存在 SQL 注入漏洞。如果存在漏洞,攻击者可以继续进行下一步操作。 ### 步骤 2:...
基于优化的GNN攻防在这项...(*平等贡献) @inproceedings{xu2019topology, title={Topology Attack and Defense for Graph Neural Networks: An Optimization Perspective}, author={Xu, Kaidi and Chen, Hongge and
此外,报告中还提到了一些其他重要的市场参与者,如Liaoning Kelong、Takemoto、Huangteng Chemical、Kao Chemicals、Arkema、Shanxi Kaidi等,它们在不同地区和细分市场中发挥着重要作用。这些企业的存在和表现,...
报告中提到的主要生产商包括Linak、Phoenix Mecano、Jiecang、Loctek Motion、Timotion、Thomson Industries、Suspa、Kaidi、Progressive Automations、RICHMAT等。2021年,这五家公司在全球市场的份额总计约50.0%,...
【输灰仓泵检修文件包】是针对XX凯迪绿色能源开发运营XXWuhan KaiDi Green Energy Development And Operation Co., LTD旗下的12MW机组锅炉检修的重要文档,旨在规范和指导输灰仓泵的维护和检修工作,确保设备的正常...
By Kaidi, ZHU, R&D Engineer of and . 正确打开姿势 预备工作:请确保已安装 Node.js 在你的电脑。 安装 依赖。执行 $ npm install。 启动它,执行 $ npm start 。 在弹出的浏览器窗口中点击 tasted.md 即可。 若非...