2017/01/14

MIT App Inventor 2 - Voice Recognition

Hi Guys, I wished you all had a happy holidays!

It's been a while since I published my last tutorial.  This morning, when I checked MIT App Inventor 2 web editor, I found few new interesting new components.

One of them specially caught my eyes is the "SpeechRecognizer" under Media block.
Checked the explanation on the right, I decided to do a quick test on this new component.


What I want to do here is very simple:
  1. Click "Speak" button to talk to the App
  2. The App send the voice to SpeechRecognizer 
  3. The App then show the particular sentence into a Text next to "You've said"

Here is the Screen1 Layout:
Here are all the components I've used in this tutorial, a button, two labels, and SpeechRecognizer1 component as shown below.





Here are the programming blocks. Only few blocks to get the Speech Recognizer to work. I was very surprised!

First, initial varibles and text to blank or "".

Secondly, when "SpeakBTN" clicked, just call "SpeechRecognizer1" to GetText. 




After get your Voice to Text, just set it to label.







Well, that's all need you do do the complete Voice Recognizer App.
See the YouTube Video for the demo below.



I guess you might want to give it a try now!

The End.
==================================================================
哈囉大家好,但願大家都有一個開心的假期!

距離上次我發布新的教學已經有一段時間 了。這個早上,我在查看MIT App Inventor 2時
我發現了幾個有趣的新東西。

第一個吸引我的目光的是音樂裡的「聲音辨識」。看一下解釋後,我決定針對這個新東西做個小測試。

我要做的測試非常簡單:

  1. 按下「說話按鈕」後對他說話
  2. 程式把你說的話丟給聲音辨識系統
  3. 辨識完後再將你說的話顯示出來

Here is the Screen1 Layout:
下圖是這次測試所用到的原件,一個按鈕、兩個文字元件和一個聲音辨識元件。





這些是程式方塊。其實,只要這些方塊就能使聲音辨識起作用讓我還蠻驚訝的呢!

首先,先設定變數和把文字設定成空格。


再來,當「說話按鈕」被按下時,就叫聲音辨識元件辨識並得到字串.








當系統辨識完後,就將它設成文字。








只要有上方這幾行程式就能完成你的聲音辨識App了。
請觀看底下的示範影片。


我想你現在一定迫不及待想去試試看了吧!

2 comments:

  1. 很精采的示範,還有中英文雙語示範影片,真是太棒了。
    感謝您的分享

    ReplyDelete