- start同声同译后如何onFrameRecorded获取数据?
为什么微信小程序录音recorderManager.onFrameRecorded((res)=>正常录音和获取数据,但是在同声同译的recordRecognition.start({lang: "zh_CN", duration: 2560});后,就再也触发不了onFrameRecorded,如何解决?同声同译的start同时也能onFrameRecorded获取数据做人声简易判断mffc。如果停止mffc获取数据转start同声同译,这样可以误判,可以随时cancle同声同译。现在本地record是recorderManager.start({format:"pcm",sampleRate:16000,frameSize:0.3,numberOfChannels:1,duration:60000});,请问是不是sampleRate:16000,frameSize:0.3与同声同译一样就可以保证同步onFrameRecorded获取数据,那么同声同译的sampleRate:16000,frameSize:0.3参数又是多少?麻烦给建议,谢谢。如果单独只是执行同声同译start后如何保证onFrameRecorded获取数据?谢谢。
11小时前 - 一个worker的postMessage,代码片段老是跑不出来啊?
微信跑一个worder的简单例子,老是跑不了,除了上面代码片段,还有https://developers.weixin.qq.com/s/1ABYYTms881V。有人说:代码片段 不会真正打包 workers 目录,导致 workers/wk.js 根本没被编译进包,所以 主线程发出的消息永远收不到。但是我弄了一个项目,跑了也报同样错误。不知什么原因?麻烦大家给个解决方案,别沉默哦。
07-25 - 本地如何加载rnnoise.wasm?
微信小程序本地如何加载rnnoise.wasm? 文件为https://github.com/jitsi/rnnoise-wasm/tree/master/dist下载所得 // rnnoise.js(最终版) export function load() { return new Promise((resolve, reject) => { const path = `${wx.env.USER_DATA_PATH}/../rnnoise.wasm`; // 无论文件目录怎么改都不行。 wx.getFileSystemManager().readFile({ filePath: path, success(res) { const bytes = new Uint8Array(res.data); WXWebAssembly.instantiate(bytes, {}) .then(({ instance }) => resolve(instance.exports)) .catch(reject); }, fail: reject }); }); } ------------------------------------- const fs = wx.getFileSystemManager(); const wasmFilePath = `${wx.env.USER_DATA_PATH}/rnnoise.wasm`; // 确保路径正确 // 检查文件是否存在 fs.access({ path: wasmFilePath, success: () => { // 文件存在,读取文件 fs.readFile({ filePath: wasmFilePath, encoding: 'binary', success: (res) => { const wasmBuffer = res.data; this.initializeWasm(wasmBuffer); }, fail: (err) => { wx.showToast({ title: '读取文件失败', icon: 'none', }); console.error('读取文件失败', err); }, }); }, fail: () => { wx.showToast({ title: '文件不存在,请检查路径', icon: 'none', }); console.error('文件不存在,请检查路径'); }, }); 提示:'文件不存在,请检查路径'
07-24 - cameraContext.onCameraFrame((frame) =>{获取像素问题}?
尊敬的微信团队,求教一个问题,新手,实在搞不懂。 cameraContext.onCameraFrame((frame) => { let uint8Array=new Uint8ClampedArray(frame.data); for(var h=0;h<height;h++) { for(var w=0;w<width;w++) { var pixelIndex=((h*width)+w)*4;//rgba; var pixelRed=uint8Array[pixelIndex]; var pixelGreen=uint8Array[pixelIndex+1]; var pixelBlue=uint8Array[pixelIndex+2]; } } } 问题: 上代码获取pixelRed和pixelGreen和pixelBlue都为零?想获取pixelBlue的值0~255,如何实现,谢谢了。 麻烦回复,恳教大家帮帮忙,就是要从frame.data获取每个像素点的r g b值。麻烦了。
2021-04-21 - 如何引用crypto,const crypto = require("crypto");报错?
确认安装了nodejs -v v14.16.0 在微信开发工具 const crypto = require("crypto"); 报 "crypto.js" is not defined. 外部命令 node v3.js没有报错,但是开发工具const crypto = require("crypto");老是报错,请问如何解决?麻烦了。 const crypto = require('crypto'); function sha256(message, secret = '', encoding) { const hmac = crypto.createHmac('sha256', secret) return hmac.update(message).digest(encoding) } function getHash(message, encoding = 'hex') { const hash = crypto.createHash('sha256') return hash.update(message).digest(encoding) } function getDate(timestamp) { const date = new Date(timestamp * 1000) const year = date.getUTCFullYear() const month = ('0' + (date.getUTCMonth() + 1)).slice(-2) const day = ('0' + date.getUTCDate()).slice(-2) return `${year}-${month}-${day}` } function main(){ // 密钥参数 const SECRET_ID = "Aetet*" const SECRET_KEY = "sdfasdf" const endpoint = "iai.tencentcloudapi.com" const service = "iai" const region = "ap-beijing" const action = "DetectFace" const version = "2020-03-03" //const timestamp = getTime() const timestamp = Math.round(new Date().getTime()/1000) + ""; //时间处理, 获取世界时间日期 const date = getDate(timestamp) // ************* 步骤 1:拼接规范请求串 ************* const signedHeaders = "content-type;host" const payload = "{\"Image\": \"\"}" const hashedRequestPayload = getHash(payload); const httpRequestMethod = "POST" const canonicalUri = "/" const canonicalQueryString = "" const canonicalHeaders = "content-type:application/json; charset=utf-8\n" + "host:" + endpoint + "\n" const canonicalRequest = httpRequestMethod + "\n" + canonicalUri + "\n" + canonicalQueryString + "\n" + canonicalHeaders + "\n" + signedHeaders + "\n" + hashedRequestPayload console.log(canonicalRequest) console.log("----------------------------") // ************* 步骤 2:拼接待签名字符串 ************* const algorithm = "TC3-HMAC-SHA256" const hashedCanonicalRequest = getHash(canonicalRequest); const credentialScope = date + "/" + service + "/" + "tc3_request" const stringToSign = algorithm + "\n" + timestamp + "\n" + credentialScope + "\n" + hashedCanonicalRequest console.log(stringToSign) console.log("----------------------------") // ************* 步骤 3:计算签名 ************* const kDate = sha256(date, 'TC3' + SECRET_KEY) const kService = sha256(service, kDate) const kSigning = sha256('tc3_request', kService) const signature = sha256(stringToSign, kSigning, 'hex') console.log(signature) console.log("----------------------------") // ************* 步骤 4:拼接 Authorization ************* const authorization = algorithm + " " + "Credential=" + SECRET_ID + "/" + credentialScope + ", " + "SignedHeaders=" + signedHeaders + ", " + "Signature=" + signature console.log(authorization) console.log("----------------------------") const Call_Information = 'curl -X POST ' + "https://" + endpoint + ' -H "Authorization: ' + authorization + '"' + ' -H "Content-Type: application/json; charset=utf-8"' + ' -H "Host: ' + endpoint + '"' + ' -H "X-TC-Action: ' + action + '"' + ' -H "X-TC-Timestamp: ' + timestamp.toString() + '"' + ' -H "X-TC-Version: ' + version + '"' + ' -H "X-TC-Region: ' + region + '"' + " -d '" + payload + "'" console.log(Call_Information) } main()
2021-03-15 - 支付回调:有返回成功信息,还是多次回调?
支付成功后,回调时,回复了下面信息: <xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml> 还是执行十次以上回调,如何处理,谢谢!
2021-02-28 - <canvas type="2d" id="canva"/> .exec((res) =>执行错误?
尊敬的微信团队: <canvas type="2d" id="canvas'"/> const query = wx.createSelectorQuery() query.select('#canvas').fields({ node: true, size: true }) .exec((res) => {} 执行这一句老是提示:TypeError: Cannot read property 'createView' of undefined错误,如果去除type="2d"就不会错误,但是获取不到node,node==null; }); 求人,谢谢。
2021-02-23 - 问onUploadTaskStateChange 1、2、3、4... not found问题?
问下大家,我的var uploadTask=wx.uploadFile({...})老是出现了onUploadTaskStateChange 1、2、3、4... not found问题,请问如何解决? 还有,wx.uploadFile在执行中如何中断它? 谢谢!
2021-02-16 - canvasToTempFilePath第二参数无论怎么整都是fail canvas is emp?
下面代码,无论that放哪里,怎么整都提示:fcanvasToTempFilePath: fail canvas is empty,真是无语,麻烦求解,谢谢。 onReady: function () { var that = this; var context = wx.createCanvasContext('mycanvas',that); wx.chooseImage ({ success: function (res) { context.drawImage(res.tempFilePaths[0], 0, 0, 150, 100); context.fillStyle = "#FF0000"; context.fillRect(0, 0, 50, 50); context.draw(true, setTimeout(function() { wx.canvasToTempFilePath ({ destWidth: 150, destHeight: 100, canvasId: 'mycanvas', success: function (res) { console.log('1212' + res.tempFilePath); }, fail: function (res) {console.log(res);} },that); },300)); } }); }
2021-01-04 - 问userInfo: {}什么意思?userInfo: {}和userInfo: null区别?
问userInfo: {}什么意思?userInfo: {}和userInfo: null区别?
2020-12-22