Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
is there a way to use speech recognition in an Iionic 2 Project? All I came across are possibilities for Ionic 1 like in this post Speech recognition using ionic framework . Ionic 2 already provides a native API for Text to Speech http://ionicframework.com/docs/v2/native/texttospeech/ but I would need it the other way round.
Better question to ask yourself is, is there a cordova plugin for the thing I want?
And yes there are cordova plugins available.
https://github.com/macdonst/SpeechRecognitionPlugin
https://github.com/poiuytrez/SpeechRecognizer
Just instead of using cordova plugin add ..... use ionic plugin add ...... (will immediately update platforms).
You can use this Cordova plugin for speech recognition cordova-plugin-tts
Since Ionic 2 uses TypeScript ,all you need is a way to use the plugin with TypeScript .The Github repo includes an example on how to do that
declare module TTS {
interface IOptions {
/** text to speak */
text: string;
/** a string like 'en-US', 'zh-CN', etc */
locale?: string;
/** speed rate, 0 ~ 1 */
rate?: number;
}
function speak(options: IOptions, onfulfilled: () => void, onrejected: (reason) => void): void;
function speak(text: string, onfulfilled: () => void, onrejected: (reason) => void): void;
}
Related
I am quite new to RN . I know this question is being repeated but I didn't quite get ans I was looking for there .
So my current project uses
expo for web and react-native cli for the android set up .
I want to add an image-picker to the project.
I see two options at my side .
RN-image-picker
expo-image-picker
I have some issues and some questions !!
Is RN-native-image picker comaptible with web ??
I think its not ,there are two resons I think that ,this lib uses Nativemodules, which
won't be bundled for web and its giving undefined error for NativeModules when I run with
web while it works fine on android .
Should I use expo-image-picker when I am creating a android build with react-native cli ??
The build doesn't give errors and it shouldn't ,but when I click on upload image ,app
crashes after I select image.I read the docs and github for the issue.Many people pointed
out its ram allocation issue,which can be sorted with disbaling "Dont keep activities" in
developer's option,which I haven't tried yet .
Also on web ,the following code snippet returns base64 as uri,is it default behaviour ??
I am using this code snippet for expo-image-picker,which ends up crashing app when I build app with rn cli,but doesn't seem to cause issues with expocli build.But I want to use expo for web and rn for android.
Also on web ,the following code snippet returns base64 as uri,is it default behaviour ??
const pickImage = async () => {
try{
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
base64:false
})
if(!result.isCancelled)return result.uri ;
}catch(err){
console.log(err) ;
}
}
So what should I do in this case,use expo-image-picker as it seems to be compatible with all platforms/both ?
Any kind of input would be helpful !!
I'm not a fan of Expo, and I don't have experience with that but I try to answer to your question that can be.
Is RN-native-image picker comaptible with web ??
You have right, the library supports only mobile devices.
Should I use expo-image-picker when I am creating an android build with react-native cli ??
From expo documentation, I read that but I know also that sometimes the rn-cli and expo has some package differences, and this answer proves that.
Expo never locks you in, you can "eject" at any time and your project will just be a typical native project with the React Native and Expo SDK packages that your app is using installed and configured.
I don't know what the exception, and maybe the solution that you put in your answer work well, but maybe is possible to have some dependency mismecc? Such as a none object on the Web app? or something like that.
Also on web ,the following code snippet returns base64 as uri,is it default behaviour ??
This looks like be an bug and this issue on github maybe can confirm my idea
I am trying to deploy a simple script to AWS Lambda that would generate critical css for a website. Running this serverless seems to make sense (but I cannot find any working examples).
The problem is with package size. I am trying to use https://github.com/pocketjoso/penthouse. When I simply npm install penthouse suddenly the package size is over 300MB. Size limit on Lambda is only 250MB and it will not upload.
Is there any way to solve this? Perhaps download penthouse on the fly? If so, is there any example?
Performance is not so critical in this case as it would be called only a few times a day by an automated process.
Looking at the bundle size of the package (https://bundlephobia.com/result?p=penthouse), it doesn't appear that your issue is primarily with the penthouse package. Although I cannot say for certain, I think it's mainly down to the size of your other dependencies.
Nevertheless, seen as this isn't a critical system and will be accessed a few times a day via automation processes, you can reduce the size of your node_modules folder by using a CDN.
There are a number of services which allow you to do this, I have primarily used UNPKG and jsDelivr in the past as they appear to be reliable with minimal-to-no downtime.
I lack the required detail from your question regarding which technology you're specifically using and the extent you can go to in order to achieve your desired result, but there are a few options you can choose:
Utilise webpack's externals configuration:
https://webpack.js.org/configuration/externals/
Use a CDN library loader such as: https://www.npmjs.com/package/import-cdn-js
Or https://www.npmjs.com/package/from-cdn
loadjs is another option: https://github.com/muicss/loadjs
scriptjs https://www.npmjs.com/package/scriptjs
I don't know much about penthouse but with scriptjs, I assume you can achieve something like this:
var penthouseScript = require("scriptjs");
penthouseScript("https://cdn.jsdelivr.net/npm/penthouse#2.2.2/lib/index.min.js", () => {
// penthouse related code
penthouse({
url: 'http://google.com',
cssString: 'body { color: red }'
})
.then(criticalCss => {
// use the critical css
fs.writeFileSync('outfile.css', criticalCss);
});
});
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
So this question has been asked before, but the general answer pointed to was using an external library such as cURLpp. So I was curious as to if HTTP requests could be done using only the standard libraries as of C++14. How difficult would this be?
Say for example, I wanted to get an XML document and store it in a string to be parsed. What steps would have to be taken to achieve this?
If anyone is curious, I'm doing this as a learning experience to better understand how HTTP requests work.
It sounds like to me that you want to implement the HTTP protocol from scratch on top of the POSIX sockets API. I have done this myself, it was quite fun.
Read about the sockets API here: http://en.wikipedia.org/wiki/Berkeley_sockets
If you want to work on Windows, see here.
This link, posted in the comments, provides a pretty good starting-point example for using the API, although it weirdly includes both the client and the server as serial logic within the same program -- which may allow it to bypass some of the calls (such as waiting for incoming connections) required to implement a client or server as a standalone program.
Assuming you are implementing an HTTP server in C++, you might choose to implement the client as a web page (running on your favorite browser), as the following hack demonstrates...
<html>
<head>
</head>
<body>
This web page sends the entered text back to the server upon a button press.
The server's response is then displayed in the box below.
This is only a hack for learning purposes, and not a demonstration of best-practices.
<br>
<textarea id="INP">
Hello world!
</textarea>
<br>
<button onclick="return make_request('INP','GET','test1')">GET Request</button>
<button onclick="return make_request('INP','POST','test2')">POST Request</button>
<div id="result" style='border-style:solid;'>?</div>
<script>
function make_request( textID, request_type, webfn )
{
var url = "" + "?webfn="+webfn // assumes this page was served by the same server
if ( request_type != 'POST' ) url += "&value="+document.getElementById(textID).value;
var req = new XMLHttpRequest();
req.open( request_type, url, /*async*/false );
req.send( request_type=='POST' ? document.getElementById(textID).value : null );
if ( req.readyState == 4/*complete*/ && req.status == 200/*OK*/ )
{
result = req.responseXML.documentElement.getElementsByTagName('value')[0].firstChild.data;
document.getElementById('result').innerHTML = req.responseText;
}
else alert("HTTP request failed");
return false;
}
</script>
</body>
</html>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am on project right now which is a very simple parental control software, but, I want to know what is the url requested in firefox to take respond based on it ... if you may help because I don't know how to let my software know what is the url requested by firefox .. How to do that?
I have to use C++ in most of my software.. but if there are better language to do this task please advice me
In Firefox you need to use XPCOM component called nsIHTTPChannel. This script below will block abort all rqeuests to google. The channel is opened but aborted before opening connection to server.
var {classes: Cc, results: Cr, utils: Cu} = Components;
Cu.import('resource://gre/modules/Services.jsm');
var httpRequestObserver =
{
observe: function(subject, topic, data)
{
var httpChannel, requestURL;
if (topic == 'http-on-modify-request') {
httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
requestURL = httpChannel.URI.spec;
if (/google\.com/.test(requestURL)) {
httpChanel.cancel(Cr.NS_BINDING_ABORTED);
}
return;
}
}
};
Services.obs.addObserver(httpRequestObserver, 'http-on-modify-request', false);
//Services.obs.removeObserver(httpRequestObserver, "http-on-modify-request", false); //run this to remove observer
Can I suggest an alternative approach? Instead of writing an extension for Firefox and an extension for Chrome and an extension for IE... listen on the OS network interfaces for traffic and block undesirable URLS.
This is traditionally the job of a firewall. Using an existing solution will provide the most efficient means of solving your problem. I'm not familiar with the capabilities of the built in Windows firewall or 3rd party alternatives but something like this would be trivial with iptables (Linux).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I have the following behaviour with Ember Data 1.0.0 Beta 2:
Rollback of data changes (without first trying to save the changes):
- all data properties are restored to the previous version
- all flags in correct state
Rollback of data changes after an attempt to save, but the save returned a 422 error:
- none of the data properties are restored
- isError flag remains true
I would expect that also in the second case the properties are set back to the previous state and that the isError flag is cleared.
This is how I revert:
cancel: function () {
var author = this.get('model');
author.rollback();
},
Is this a known issue ?
thx