# How can I implement voice recognition in JAVA mode?

**URL:** <https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713>\
**Category:** Libraries\
**Created:** [April 29, 2021, 1:16am UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713 "2021-04-29T01:16:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [April 29, 2021, 1:16am UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/1 "2021-04-29T01:16:02Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

How can I implement voice recognition in JAVA mode?

```auto
 import com.getflourish.stt.*;
 import ddf.minim.*;
 import javax.sound.sampled.*;
  
 STT stt;
 String result;
 String key = "key";
  
 void setup ()
 {
   size(600, 200);
   // Init STT automatically starts listening
   stt = new STT(this, key);
   stt.enableDebug();
   stt.setLanguage("en"); 
   
   // Display available Inputs with id and name
   Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
  
   for(int i = 0; i < mixerInfo.length; i++)
   {
     println("### " + i + ": " + mixerInfo[i].getName());
     
     
   }  
   
   // Set input (e.g. 0)  
   Mixer mixer = AudioSystem.getMixer(mixerInfo[6]);
   
   // Update the Minim instance that STT is using
   Minim minim = stt.getMinimInstance();
   minim.setInputMixer(mixer);
   println("### Source set to: " + mixerInfo[6]);
  
 }
  
 // Method is called if transcription was successfull 
 void transcribe (String utterance, float confidence) 
 {
   println(utterance);
   result = utterance;
 }
 public void keyPressed () {
   stt.begin();
 }
 public void keyReleased () {
   stt.end();
 }
  
 void draw ()
 {
   background(0);
 }

```

![stt](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1925e14999a3ef3405d80f1950bcc1f92e732ee2.jpeg)

You have been given an API key. (From Google)  
But, it doesn’t work.  
I think that’s because the SST library is old.  
Is there any solution?

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 29, 2021, 8:33am UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/2 "2021-04-29T08:33:47Z")

</div>

please format your code with `</>` button not `”` 🥺

You mean you replaced the key variable with an actual API key, right? As you pointed out it seems like an old library and most likely the protocol has changed.

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [April 29, 2021, 3:54pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/3 "2021-04-29T15:54:28Z")

</div>

It seems that the library is out of date and cannot be started.

I am curious to see if anyone has solved it, so I post it.

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 29, 2021, 6:20pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/4 "2021-04-29T18:20:47Z")

</div>

yes otherwise it may be easier to send data to python scripts or something that already has a library.

but first,

🥶 🤖 💀 👽 please format your code with `</>` button not `”` 👹 😈 😺 🤡

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 29, 2021, 7:15pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/5 "2021-04-29T19:15:56Z")

</div>

> [@GWAK](#):
>
> I am curious to see if anyone has solved it, so I post it.

I am curious why you are not properly formatting your code; this was requested in other topics as well.

As a courtesy to everyone in this community please format your code:

[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

You can use the edit button (looks like a pencil):  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/ea66ff565e030b0508baa76d9d76eeab272ae0d4.png)

`:)`

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 30, 2021, 1:57pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/6 "2021-04-30T13:57:38Z")

</div>

[https://www.khm.de/~n.hieda/discourse-code.mp4](https://www.khm.de/~n.hieda/discourse-code.mp4)

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [May 1, 2021, 9:30am UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/7 "2021-05-01T09:30:04Z")

</div>

@micuat  
@glv  
thank you for your answer.

However, I would like you to be interested in solving my solution.

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [May 1, 2021, 9:57am UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/8 "2021-05-01T09:57:03Z")

</div>

but we want you to be interested in the fact that this is a community and we are not here to serve you 🙂 And I already wrote that maybe you should look into libraries for other languages like python to do it and connect the programs somehow because I cannot help you further. I hope someone else would jump in and answer, but for that, formatting the code definitely helps “someone” look into the problem - they might turn away if they look at an unformatted code like you posted at first.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 1, 2021, 4:27pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/9 "2021-05-01T16:27:36Z")

</div>

> [@GWAK](#):
>
> However, I would like you to be interested in solving my solution.

I found a workaround by the author.

However, I will leave this as an exercise for you to find.

`:)`

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [May 2, 2021, 11:24pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/10 "2021-05-02T23:24:54Z")

</div>

@micuat  
You are saying that Java alone cannot solve it.  
Thank you for your answer. Let’s find a solution.

Is it correct that I understand?

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [May 2, 2021, 11:26pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/11 "2021-05-02T23:26:45Z")

</div>

@glv

I solved it through Android.

However, I’m not sure how to implement it via Java.

If you know the reference link,  
I would appreciate it if you share it.

Thank you for your interest.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 2, 2021, 11:40pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/12 "2021-05-02T23:40:45Z")

</div>

> [@GWAK](#):
>
> If you know the reference link,  
> I would appreciate it if you share it.

[https://florianschulz.info/stt/](https://florianschulz.info/stt/)

And it works!

`:)`

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [May 2, 2021, 11:53pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/13 "2021-05-02T23:53:39Z")

</div>

@glv  
Thank you for good information.

Thank you.

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [May 3, 2021, 7:14am UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/14 "2021-05-03T07:14:17Z")

</div>

No. I meant even if the library doesn’t work, it’s not the dead end but you can be “creative” to find other solutions 🙂

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 3, 2021, 5:43pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/15 "2021-05-03T17:43:31Z")

</div>

@GWAK,

Can you please elaborate on what the _solution_ is?

`:)`

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [May 4, 2021, 4:01am UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/16 "2021-05-04T04:01:53Z")

</div>

@glv

It was not resolved through the JAVA program.  
I used it through Google STT in Android.  
android can be easily implemented. However, it seems difficult with JAVA.  
I’m currently looking for a solution.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 4, 2021, 3:11pm UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/17 "2021-05-04T15:11:30Z")

</div>

> [@GWAK](#):
>
> I’m currently looking for a solution.

You tagged a post in this topic as a solution; this post is advice but not a solution.

Perhaps you should “like” posts and tag a solution when it is found.

`:)`

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [May 5, 2021, 12:01am UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/18 "2021-05-05T00:01:56Z")

</div>

We have confirmed that there is a solution through’websocket’.  
thanks to you…

However, in order to be the system I want, JAVA must be run internally.  
So, I need to do more research.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 5, 2021, 12:33am UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/19 "2021-05-05T00:33:57Z")

</div>

> [@GWAK](#):
>
> So, I need to do more research.

Please share when you find something that works.

`:)`

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [May 5, 2021, 9:43am UTC](https://discourse.processing.org/t/how-can-i-implement-voice-recognition-in-java-mode/29713/20 "2021-05-05T09:43:24Z")

</div>

@glv

I’m not looking for something else right now.

We are trying to solve it by looking for a number of ways.

If it is resolved, we will post it in a later notice.

Thank you.
