tgraupmann / UnityWebGLMicrophone

WebGL Microphone module for Unity
MIT License
107 stars 23 forks source link

Microphone.Start Replacement #4

Open BenWindley opened 4 years ago

BenWindley commented 4 years ago

Hey! I was wondering if you have a replacement for Microphone.Start? Since I'm not sure how to make it record audio yet since the demo only has audio volumes.

chopin1998 commented 2 years ago

same problem..

iamkim17 commented 1 year ago

any news from how to call the microphone.start?

tgraupmann commented 1 year ago

I actually had success using the Recorder.js library. It has a nice recorder with start, stop, clear, and getBuffer methods. I used it to capture Microphone data that feeds directly into the Whisper AI model for speech detection and it works flawlessly for multiple languages. https://github.com/tgraupmann/ChromeOS_Whisper/blob/main/Server.html

muhammadabdigit commented 1 year ago

Dear Timothy, I hope you are great.

First of all, thanks for sharing your Unity WebGL Recorder and I'm also glad to hear that you were able to integrate it with Whisper. I would really appreciate it if you could share with us some information about how to use this recorder in Unity WebGL. I look forward to hearing from you.

with all respect, Muhammad

iamkim17 commented 1 year ago

Hi @tgraupmann

Thank you for providing us with the details, but may I know how to create a jslib from this so that I can access it through unity? sorry, still learning javascript

tgraupmann commented 1 year ago

You can see sample JSLib code here - https://github.com/tgraupmann/UnityWebGLMicrophone/blob/master/Assets/Plugins/WebGL/MicrophonePlugin.jslib

The syntax is similar to HTML5 with slightly different syntax for passing strings between Unity C# classes and the JS code.

iamkim17 commented 1 year ago

Thank you @tgraupmann . I can see that its similar syntax with your Server.html. It makes sense now.

Thank you again!

iamkim17 commented 1 year ago

Hi again @tgraupmann I tried editing the MicrophonePlugin.jslib to the one you used in whisper AI, but I have no luck. Do you have any plugin just we can buy or free to use? I've been looking for a solution for almost 1 month. Thanks!

tgraupmann commented 1 year ago

I don't always see Github notifications. Ping me on Discord - Tim Graupmann#0611

StephenHodgson commented 1 year ago

Bumping this for interest

tgraupmann commented 1 year ago

I'll need this logic as well. I need to make an AI model for audio detection and then I'll need to update the Microphone JS library.

tgraupmann commented 1 year ago

I added some visualization for the volume data and wave data. https://github.com/tgraupmann/UnityWebGLMicrophone/blob/master/Test/index.html

image

The raw data for your audio clip is in document.dataArray.

tgraupmann commented 1 year ago

It looks like the browser encodes audio in audio/webm format so you have to use an analyzer to get the raw wave data. To get the data available events to fire, I needed to start and stop the audio source. As long as all the data keeps getting appended to an array, it should be ready for an audio clip if you slice the extracted data as it is being read.

image

StephenHodgson commented 1 year ago

That's been my problem too, getting the data usable to be set in the audio clip PCM data