edimuj / cordova-plugin-audioinput

This iOS/Android Cordova/PhoneGap plugin enables audio capture from the device microphone, by in near real-time forwarding audio to the web layer of your application. A typical usage scenario for this plugin would be to use the captured audio as source for a web audio node chain, where it then can be analyzed, manipulated and/or played.
https://github.com/edimuj/app-audioinput-demo
MIT License
161 stars 88 forks source link

capacitor version? #126

Closed Arpapiemonte closed 1 year ago

Arpapiemonte commented 1 year ago

Hi, I'm trying to use this plugin with a ionic-capacitor app I can install the plugin with (https://capacitorjs.com/docs/plugins/cordova):

npm install cordova-plugin-name
npx cap sync

With an angular app I manage to use the cordova-plugin. With a vue app I can't.

Is scheduled a development of a capacitor version? Is this plugin mantained?

Thanks

edimuj commented 1 year ago

Capacitator support would be a very welcome addition. I haven't much time to maintain this plugin myself nowadays, but it is an open-source project, so any one who wants to contribute to it are welcome to file a PR.

losciur commented 1 year ago

Hi @edimuj , sorry if I didin't reply, but I haven't time and knowledge to help you in this work. I hope someone could help. Thanks

edimuj commented 1 year ago

No problem at all!

jukefr commented 1 year ago

fyi for future reference for people finding this issue, had no problems with a capacitor and react project. Just install package and npx cap sync. And setup for typescript like explained in the readme of the repo. I dont know about vue but should also be fine. (the fact the poster seems to say it worked for them on angular with capacitor also does seem to point that something was just done wrong on their end in the vue template) Make sure to put the permission check inside of a useEffect call to make sure the components are actually all loaded right and thats about it. The "webaudio live output" does not seem to work right though on android (just crackles) but thats another issue that doesnt concern this and is already brought up in other already opened issues. I ended up just having to use an encoder to just check that the raw pcm data we capture was actually good and it was.

[...]
  const startCapture = async () => {
    audioinput.start(audioCfg );
  };

  useEffect(() => {
    // Check if we already have permission to record
    audioinput.checkMicrophonePermission(function (hasPermission: boolean) {
      if (hasPermission) {
        console.log("We already have permission to record.");
      } else {
        // Ask the user for permission to access the microphone
        audioinput.getMicrophonePermission(function (
          hasPermission: boolean,
          message: string
        ) {
          if (hasPermission) {
            console.log("User granted us permission to record.");
          } else {
            console.warn("User denied permission to record.");
          }
        });
      }
    });
  }, []);
[...]

nb: if you dont actually need to specifically have the raw audio stream pcm data as chunks "in real time" i would recommend other plugins with easier interfaces but i need this and im happy for now :)

edimuj commented 1 year ago

Thank you @jukefr !