GithubHelp home page GithubHelp logo

Comments (17)

miguelmota avatar miguelmota commented on September 21, 2024 1

I think you need to call .stop() on the MediaStream object to completely stop streaming from that media channel.

var localStream = null;
navigator.getUserMedia({
  audio: true
}, function(stream) {
  localStream = stream;
  // ...
}, function(error) {});

// later
localStream.stop();
recognition.start();

from pocketsphinx.js.

Villmer avatar Villmer commented on September 21, 2024

I see someone else has had the same issue: http://sourceforge.net/p/cmusphinx/bugs/396/
Has there been any solution to this on Android?

from pocketsphinx.js.

Villmer avatar Villmer commented on September 21, 2024

By the way, the Google Web SpeechRecognition does TRY to begin (you hear it beep) but then it immediately turns off (another beep) as it encounters a conflict accessing the mic.

How can I (temporarily) shot off pocketsphinx.js (recorder) to free up the mic? Can I?

from pocketsphinx.js.

syl22-00 avatar syl22-00 commented on September 21, 2024

I do not really understand what you are doing and your issues do not seem to be related to pocketsphinx.js.

  1. Your link points to an issue in pocketsphinx, not pocketsphinx.js.
  2. pocketsphinx.js runs in the browser, the platform on which the browser runs does not matter.
  3. If you find issues with the recorder, you might want to look at forums around webRTC, getUserMedia, and the browser you are using. Also, you can try with different web browsers.

from pocketsphinx.js.

Villmer avatar Villmer commented on September 21, 2024
  1. Yes, I know the link points to a pocketsphinx issue. However, the issue is identical for HTML5 /Javascript based apps running in Android (via Cordova)
  2. The pocketSphinx.js + Google combination works fine in the desktop browser. Using the EMBEDDED Chrome browser (Crosswalk) in Android, however, does NOT work.

On Android, the mic can only be utilized by one thing at a time. It's either Google (SpeechRecognition) or pocketSphinx.js. (not at the same time). Because pocketSphinx.js is such a complex platform, I was just curious if there was a way to just turn it OFF (and back ON again) to free up the audio.

None of the following successfully stopped pocketSphinx so I could use Google SpeechRecognition:

  1. audioContext.close()
  2. postRecognizerJob({command: 'stop'})
  3. stopRecording() ---> function stopRecording() { if(recorder && recorder.stop()){}};

from pocketsphinx.js.

nshmyrev avatar nshmyrev commented on September 21, 2024

If you want to run on Android, pocketsphinx.js will certainly be too slow

You need to create a simple Cordova plugin. It's not very complex, you just integrate pocketsphinx-android jar and jni library and call them with javascript. Recording is better performed on java side as well, not in javascript.

from pocketsphinx.js.

Villmer avatar Villmer commented on September 21, 2024

@nshmyrev
Actually the speed of pocketsphinx.js is very fast on my Huawei p8 Max. If performance could improve through a more elegent integragtion that would be great. However, I'm not too familiar with developing cordova plugins and don't have the time to go that deep. I had hoped between pocketsphinx.js and google api I would have found a reasonably solid solution that allowed continual, high-performance voice recognition - but, alas no. There are some cordova plugins that claim "continual speech recognition" but they, like all others, expire after 60 seconds (the maximum Google permits you).

from pocketsphinx.js.

syl22-00 avatar syl22-00 commented on September 21, 2024

If your target is a Cordova app, there is really no point using pocketsphinx.js. Not only would it be slow, but it might suck a lot of memory.
You could also consider the Ispikit Cordova plugin. It is not free, but for your app (with limited sentence length), the free version might be enough.
https://github.com/ispikit/ispikit-cordova

from pocketsphinx.js.

Villmer avatar Villmer commented on September 21, 2024

Pocketsphinx.js works fine on Android. In fact, it runs quite fast on my
Huawei p8 Max.

This issue is getting it to turn on and off (so other voice technology can
work as well)

On Fri, Jan 22, 2016 at 6:19 PM, Sylvain Chevalier <[email protected]

wrote:

If your target is a Cordova app, there is really no point using
pocketsphinx.js. Not only would it be slow, but it might suck a lot of
memory.
You could also consider the Ispikit Cordova plugin. It is not free, but
for your app (with limited sentence length), the free version might be
enough.
https://github.com/ispikit/ispikit-cordova


Reply to this email directly or view it on GitHub
#51 (comment)
.

from pocketsphinx.js.

Villmer avatar Villmer commented on September 21, 2024

How do I tell pocketphoenix.js to COMPLETELY stop, including closing it's
audio context and so forth? I need to free up the mic so Google to access
it.

These did not entirely work:

  1. audioContext.close()
  2. postRecognizerJob({command: 'stop'})
  3. stopRecording() ---> function stopRecording() { if(recorder &&
    recorder.stop()){}};

On Fri, Jan 22, 2016 at 6:19 PM, Sylvain Chevalier <[email protected]

wrote:

If your target is a Cordova app, there is really no point using
pocketsphinx.js. Not only would it be slow, but it might suck a lot of
memory.
You could also consider the Ispikit Cordova plugin. It is not free, but
for your app (with limited sentence length), the free version might be
enough.
https://github.com/ispikit/ispikit-cordova


Reply to this email directly or view it on GitHub
#51 (comment)
.

from pocketsphinx.js.

syl22-00 avatar syl22-00 commented on September 21, 2024

pocketsphinx.js, the recognizer, itself does not interact with the microphone, it just gets audio samples and processes them.

Again, as I said, "you might want to look at forums around webRTC, getUserMedia, and the browser you are using."
since the microphone access is created with

var input = audioContext.createMediaStreamSource(stream);

I'd try to play around with that, such as calling disconnect or just setting it to null. If that does not help, I'd look at the MediaStream used to create the node.

from pocketsphinx.js.

Villmer avatar Villmer commented on September 21, 2024

I'll try setting "input" as a global variable and, just before calling Google SpeechRecognition object, I'll try setting input.disconnect() or input = null;

from pocketsphinx.js.

Villmer avatar Villmer commented on September 21, 2024

Nothing worked.

So, here is what we have for the pocketsphinx.js / audio recorder code...


input = audioContext.createMediaStreamSource(stream);
var audioRecorderConfig = {errorCallback: function(x) {}};
recorder = new AudioRecorder(input, audioRecorderConfig);
if (recognizer) {recorder.consumers = [recognizer];}
recorderReady = true;}, function(e) {}); }


We are dealing with the following variables (objects): "audioContext", "input" and "recorder".
On the google side, we have the "recognition" object --> recognition = new SpeechRecognition()
To start Google Speech Recognition we call "recognition.start();"

So, the goal here is to STOP or PAUSE the pocketsphinx voice and start the Google voice.
Here is the code and the things I've tried to do before calling the recognition.start() function......

if(String(n[n.length - 1])=="VOICE"){
$("#mic").show();
// TRY TO CLOSE / STOP AUDIO RECORDER/ P.S. HERE...
//input=null;
//input.close()
//input.stop()
//recorder.stop();
//audioContext.close()
//audioContext.suspend().then(function(){});
//audioContext.close().then(function(){});
//audioContext.suspend().then(function(){recognition.start();});
//audioContext.close().then(function(){recognition.start();});
//stopRecording()
//postRecognizerJob({command: 'stop'})
recognition.start(); } // START GOOGLE

All of the things I've tried are commented out. Nothing works.

from pocketsphinx.js.

Villmer avatar Villmer commented on September 21, 2024

Side question: is there a way to access confidence values with grammars in pocketsphinx.js?

from pocketsphinx.js.

obrienj970 avatar obrienj970 commented on September 21, 2024

A bit different but I have an Android C# library (built with Xamarin) that incorporates PocketSphinx Java. I got it from a third party

I use it in a service to listen for a keyword and that works fine.

When I get the keyword I cancel and stop the PocketSphinx recognizer and invoke Android's "RecognizerIntent.ActionRecognizeSpeech" to allow Android/Google to get the spoken text after a beep.

I am using PocketSphinx as a work around to the Google VR inability to do continuous recognition even at the API level. Well you can if you write a loop and enjoy a beep every 5 seconds or so.

This all works great with no microphone conflict at all.

However, if try to use RecognizerIntent.ActionVoiceSearchHandsFree or Intent("android.intent.action.VOICE_ASSIST") I get the microphone conflict.

I believe that this is an Android/Google Search Voice problem in that they appear to take a shortcut accessing the microphone which leads to the conflict.

It's not a permissions issue either, if I start my service but don't start PocketSphinx, then the Google Search Voice facilities work. As soon as I use PocketSphinx, Google Search voice support fails.

If I stop my server completely, Google Search Voice still fails. Only a reboot clears it.

As a work around, I am going to use the Google Custom Search support, accept the query in my VR code, send it to via Custom Search, and read back the responses or display them or both.

For my purposes, a 999 queries/month (free) is fine.

BTW, this issue is discussed in many forums with a number of different scenarios most of which don't involve PocketSphinx. In some cases it is device specific. A fix was supposed to be out last month but my Google App is up to date and it still fails. Strangely it used to work, about 2 months ago.

Jim

from pocketsphinx.js.

syl22-00 avatar syl22-00 commented on September 21, 2024

@obrienj970 your issue is not related to pocketsphinx.js. Pocketsphinx repo is here: https://github.com/cmusphinx/pocketsphinx

from pocketsphinx.js.

dplusic avatar dplusic commented on September 21, 2024

The way @miguelmota said works well.
stream.stop is deprecated, so please note that link.

from pocketsphinx.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.