Network Error in Web Speech API - javascript

I'm experimenting with the Demo of the Web Speech API: https://www.google.com/intl/en/chrome/demos/speech.html. You'll need version 25.0 of Chrome at least to run it.
I'm trying to use the Web Speech API continuously for a long transcription (10-15 minutes). However, I'm noticing that after roughly 1-2 minutes there is a "network" error (as mentioned in the Web Speech API Spec: https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html#dfn-onerror).
Does anyone know why this "network" error is happening pretty consistently after 1-2 minutes and if there is any way to configure the Web Speech API for longer, continuous transcriptions?
Thank you!

Web speech API usually has 60 seconds of recognition time.
You'll need to call the speechrecognition.onend() method and then call the speechrecognition.start(). So the recognition continues after stop.

Related

Uncaught TypeError: navigator.getBattery is not a function

I'm developping a website which is meant to be used on mobile devices using Google Chrome, the purpose is to list information such as time (hh:mm) and battery level.
I saw the Battery Web API but I'm experiencing a strange error:
click to see the chrome error
Here is the code I used in order to get the battery level:
navigator.getBattery().then(function (battery) {
console.log(Math.round(battery.level * 100))
});
I had the error yesterday, without changing any line of code, it is working today on my tablet (chrome version: 103), but I tested on another tablet (Samsung Galaxy TAB A7 LITE, Chrome version: 103) and I encounter the error, I restarted several times the devices, inspected pages using the devtools connected by cable to my laptop, but I can't solve this error.
I saw a topic having the same error but he was developing a web worker it is not the same context as I.
No matter when I'm calling the navigator.getBattery() if the error appeared in the beginning it will stay undefined later, so it is not a problem of timing to call it (I even bound it to the body.onload but it didn't work).
I thought it could be authorization issues on system information but there's nothing refering to the battery which is not authorized in the application settings of Chrome.
Any help is welcome :D
I found out where my error was coming from.
It is a problem of HTTPS, my testing environment is configured behind a NGINX HTTP Server, which serves HTTP and HTTPS version of my application in order to use a single certificate for every of my projects, Chrome on my laptop prefix URLs I'm accessing with https:// and it is hidden in the navbar, but it is not the case on Chrome tablet or mobile, I thought I was consulting the HTTPS version but it was HTTP, and Battery Web API isn't accessible on HTTP websites, it is required to have a secure connection using HTTPS and certificates. It has nothing to do with version number since Battery Web API is fully supported since Chrome version 38 according to MDN Documentation.

Alternative to manifest v3 chromium extension

Currently, I have developed an extension that handles a web page for 24 hours, basically an automation for a browser. But the problem I'm facing, is that the released manifest v3 doesn't allow it to work for more than 2 hours without stopping (currently, the "service work" of any manifest v3 extension works for only 5 minutes, but an open tab works for 2 hours until the entire browser crashes). I've already tried a manifest v2 extension, but the large structure of my code didn't pay off, I've already tried to create an automation using Python 3, but it didn't have much compatibility with slow computers, so in the end my client didn't like it and failed the project. Any solution? to "inject" javascript to automate a single web page for a long time, it can be per app or not, but I need ideas!

Geolocation fails if app sent to background

I'm developing a simple app with phonegap which every 30 seconds send user current coordinates to my database via ajax call.It works very well
$(document).ready(function() {
setInterval(function() {
SetLocationUpdates();
}, 30000);
});
but if the user navigates to another app(google maps app) or if I open google maps app with this code
<div><a href="geo:41.897096,27.036545">Open maps app</div>
it(sending coordinates to my database via ajax) fails because getCurrentPosition does not work maybe google maps lock it althoug my app is still work(my app and google map app work separately.Two apps work at same time.Maybe my app go background)
More specifically, it does nothing.
navigator.geolocation.getCurrentPosition(SetLocationUpdates, onError);
this line not execute.
The success or error callbacks are never called, and setting a timeout does not affect this. I am using Phonegap Build to compile the app from html and javascript.
What should I do?
You need a native background geolocation solution - JS execution on the main thread gets paused when your app goes into the background.
In my experience, the most resilient solution is cordova-background-geolocation-lt. I've tested on multiple OS versions, including Android 8 and iOS 11, and this has worked consistently on all.
Please be aware that Firefox currently continues to work when the phone is asleep or the App is backgrounded. (I believe this is a bug)
IMHO the most appropriate and battery friendly solution relies on ServiceWorkers receiving and actioning TravelEvents from the TravelManager.
See this Web App for proof of how well Background geolocation fits with ServiceWorker infrastructure. All source can be found here including a aaa_readme.txt.
Please ask W3C/IETF to standardize this and your UA vendors to implement it!

Web Worker profiling in Internet Explorer 11

According to this page https://msdn.microsoft.com/en-us/library/dn255005(v=vs.85).aspx it is possible to profile Web Worker code in Internet Explorer 11 (11.576.14393 in my case) Developer Tools (F12). But when I finish profiling, I can see only report from code running on main thread and threre is no Worker ID colum in the results as described on the mentioned page. Also, when I try to programatically start profiling from the Web Worker using Console.profile() method https://msdn.microsoft.com/en-us/library/jj152133(v=vs.85).aspx, I get error:
Object doesn't support property or method 'profile'
Do you have any clue what may be wrong? Do you please know how to profile Web Worker code in Internet Explorer?
PS: Same applies to Edge 38.14393.0.0. Rewriting the Web Worker code to run and profile it on main thread is not an option because it would take several months. The same code runs reasonably fast on Chrome and Firefox.
I tried to profile a simple web worker from the following demo
Web Worker Demo
It seems a bit weird but I was able to profile the worker only in the following scenario
I had started profiling the page and then started the worker and then stopped the worker and then stopped profiling.Exported the Data with Worker Id.
I had used IE11 in windows 7 environment.
Hope this helps :)

Too many threads in Blackberry using Phonegap/WebWorks

I am developing a Blackberry app using Cordova/PhoneGap. I am fetching several images (map tiles) from a server. Also, every 60 seconds I send position information to it.
However, every now and then either when I fetch the images or send information, I get an error. If I am on a simulator (BB 9930, OS 7.0.0.318), I get an AppError 104: Too many threads message and my app crashes. When I test my app on a device (BB 8520, OS 5.0.0.592) not only does the app crashes, but makes the BB reset.
I have seen other posts with the same issue (like this one, this one or this one). However, I haven't found a solution when building the app using Cordova/PhoneGap (JavaScript).
Thanks!
This may not be related, but I did have a similar problem when doing a lot of request from a native app on a BB Bold. The connection thread was not closed properly after receiving the answer.
try the following:
change GET <-> POST.
change HTTP <-> HTTPS.
if the server is yours, evaluate changing the API to return all the images as one and use an offset/clipping when displaying them. You will save bandwidth and open less connections. your app will load faster.
eg:
http://www.ibloomstudios.com/articles/misunderstood_css_clip/
I doubt if the phoneGap API is causing this as it is basically a layer. Possibly you have an issue with the simulator?
Since you are also testing on Blackberry 8520, It is recommended that you keep the MAX number of threads - running concurrently- at any point of time in your application - less than 12
Since you are using Phonegap, chances are that it may be initiating those threads for your application.
If the device is connected to your system, connect it to Blackberry JDE and see, which threads are active to analyse if you can reschedule your tasks.
Are you using AJAX to get the map tiles and send location to your server?
If you are using AJAX, then you can keep a counter in JavaScript to keep a check on the requests.
Also, have you tried WebWorkers , they would enable you to do all of them within single thread itself.
If all fails, you can also develop your custom Phonegap plugin to do similar things with a Java Script interface API.

Categories

Resources