baidu-aip / nodejs-sdk Goto Github PK
View Code? Open in Web Editor NEW百度AI开放平台 Node.js SDK
Home Page: https://ai.baidu.com/
License: Apache License 2.0
百度AI开放平台 Node.js SDK
Home Page: https://ai.baidu.com/
License: Apache License 2.0
// 传入可选字段
options = {"option": "cartoon"}
var fs = require('fs');
var image = fs.readFileSync("assets/example.jpg").toString("base64");
// 调用图像无损放大
client.styleTrans(image, options).then(function(result) {
console.log(JSON.stringify(result));
}).catch(function(err) {
// 如果发生网络错误
console.log(err);
});
官方文档不是说有吗
sdk 太老了,百度应该与时俱进,开发体验太差
var Client = new AipSpeechClient(APPID, APIKey, SecretKey);
Client.authTypeReq().then(() => {
let Voice = FS.readFileSync('./16k3.pcm');
let VoiceBuffer = new Buffer(Voice);
Client.recognize(VoiceBuffer, 'pcm', 16000, {lan: 'zh', cuid: APPID}).then((result) => {
console.log(JSON.stringify(result));
}, (err) => {
console.log(err);
})
});
一直返回
{"err_msg":"authentication failed.","err_no":3302,"sn":"75241621661514821783"}
尝试修改AipSpeech.js文件的asrImpl方法,在85行增加requestInfo.makeDevOptions(this.devAccessToken);
可以通过验证;
recognize方法中Options的cuid应当填写APPID,否则返回参数错误,这个在文档中没有提。
可以把 mocha 和 should 放在 devDependencies 里吗?使用时不想安装开发依赖。
https://github.com/Baidu-AIP/nodejs-sdk/blob/master/package.json
请检查AipBodyAnalysis.js
文件的 第35 行
const HAND_ANALYSIS_PATH = '/rest/2.0/image-classify/v1/driver_behavior';
请务必修改为:
const HAND_ANALYSIS_PATH = '/rest/2.0/image-classify/v1/hand_analysis';
口头警告一次
error: bundling failed: Error: Unable to resolve module crypto
from /Users/schneider/Documents/GitHub/Rock2/node_modules/baidu-aip-sdk/src/http/httpClientVoiceASR.js
: Module crypto
does not exist in the Haste module map
SamuelMactekiMacBook-Pro:Rock SamuelMac$ react-native info
React Native Environment Info:
System:
OS: macOS 10.14
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Memory: 1.09 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.13.0 - /usr/local/bin/node
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
IDEs:
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.6.3 => 16.6.3
react-native: ^0.58.4 => 0.58.4
npmGlobalPackages:
create-react-native-app: 2.0.2
eslint-plugin-react-native: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
react-native-update-cli: 0.1.0
Hi,
I meet a problem where I have no permission to access data.
I can get the result from other api like "receipt", but I cannot get access to "invoice".
Below is the code from official website:
const AipOcrClient = require('baidu-aip-sdk').ocr
var fs = require('fs');
const APP_ID = ___
const API_KEY = ___
const SECRET_KEY = ___
const client = new AipOcrClient(APP_ID, API_KEY, SECRET_KEY);
var image = fs.readFileSync("./001.jpg").toString("base64");
client.invoice(image).then(function (result) {
console.log(JSON.stringify(result));
}).catch(function (err) {
// 如果发生网络错误
console.log(err);
});
引入http模块时,大小写有误。Linux系统报错。
这里怎么还是2.4.6版本
// 调用短文本相似度
var text1 = "浙富股份";
var text2 = "万事通自考网";
client.simnet(text1,text2).then(function(result) {
console.log(JSON.stringify(result));
console.timeEnd('bdaitest');
}).catch(function(err) {
// 如果发生网络错误
console.log(err);
});
例子运行错误,提示{"log_id":2927191944377059300,"error_code":282133,"error_msg":"param text not exist"}
如何使用typescript
如何在egg中引入该插件,好方便使用
根本执行不起来呀大哥!!!
我想用在前端 请问有什么办法搞定跨域请求?
The documentation mentions the availability of English voices, and female and male persons, but whenever I try to pass anything for the option per
other than 0 for language en
I get this error:
{ err_detail: 'failed to find cluster with per and lan.',
err_msg: 'parameter error.',
err_no: 501,
err_subcode: 22,
tts_logid: 393635243 }
Is the only voice available for English is a female voice?
// 如果有可选参数
var options = {};
options["case_id"] = "123";
options["case_init"] = "123";
options["show"] = "true";
options["area"] = "100";
默认的 10s 超时对于语音识别接口来说有点短,目前的实现感觉改这个超时不太好改。直接覆盖 require('xxxx').HttpClient.DEFAULT_TIMEOUT= 1e5
不太优雅,又没有通过参数传 timeout 进去的方式。改成 requestInfo.timeout || HttpClient.DEFAULT_TIMEOUT
更好?
nodejs-sdk/src/http/httpClient.js
Line 94 in d9febf5
nodejs-sdk/src/http/httpClientVoiceASR.js
Lines 43 to 52 in d9febf5
timeout没有选项可以填写。只能在源码中修改。能否吧timeout暴露出来,变成一个选项呢?
Hello.
Can you tell how can I get the API keys and other configurations ?
I searched in the mentioned website, but didn't find there anywhere.
我相信很多的东西手册写的不清不楚的,让别人怎么用,自己看着爽了。
var HttpClient = require("baidu-aip-sdk").HttpClient;
// 上面干嘛了这个,怎么关联上下面的。总之百度就是想累死人,直接说嘛,让我们直接提交问题,累死人
var client = new AipSpeechClient(APP_ID, API_KEY, SECRET_KEY);
sbs, fuck you
使用npm i baidu-aip-sdk安装之后AipImageClassify类里面没有货币识别接口:currency
var fs = require('fs');
var image = fs.readFileSync("assets/example.jpg").toString("base64");
var templateSign = "Nsdax2424asaAS791823112";
// 调用自定义模板文字识别
client.custom(image, templateSign).then(function(result) {
console.log(JSON.stringify(result));
}).catch(function(err) {
// 如果发生网络错误
console.log(err);
});
其中这里边的
client.custom(image, templateSign)
应该改为
client.custom(image, {templateSign})
天坑
浪费我好几个小时
通用文字识别(含位置高精度版)
为什么没得url方式识别呢,别的版本却有能是为什么呢
如果有自动化测试,#2 一类的问题应该是能规避掉的。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.