Voice To Text and Text To Voice

Voice To Text and Text To Voice

Youtube Demo (No audio, screen capture only)

The sample app listens to user's voice to identify one of the following words

the app shows up the corresponding image that is identified with voice2text. you can trigger the animation or the action too. It works offline without Internet connection.

If you run it on Corona simulator, the sample project will work in debug mode and it returns a dummy word.

Sample project is here

Please open the page 1.

Art Layers


Kwik Components

Strictly Necessary to control the v2t Code process

Option

Add External Library


v2t_grp


v2t_store


but_v2t


msgTxt

The external code accesses layer.msgTxt of displayText object


anim_fish


Build for device

Publish the project and you need to add the following settings for build4/build.settings file.

Now you can build the build4 folder with Corona Simulator for android or iOS device.

You may set the flag on for Publish setting to prevent build.settings from overwritten when you publish the project for preview again.


that's all. Enjoy!

Notes

v2t_lib.lua, the sample project is configured voice2text for Japanese. You may change the language code for your preference.

local _M = {}
_M.lang = 'ja-JP'
--_M.lang = 'en-US'
--
...
...

v2t_init.lua is configured voice2text for Japanese to translate ‘cat’, ‘dog’ and ‘fish’, and ‘speak’ in Japanese characters. You may set them in your language. The words in Conv table is used to find the text string out of a result of voice2text. event.message contains a result from voice2text. The sample is configured with Japanese, so voice2text returns text in Japanese characters not a-z, A-Z Ascii. Thus Conv table is used there.

local v2tLib         = require("v2t_lib")
local v2t_STORE_LOAD = false
local isReady        = false
--
v2tLib.Conv = {cat="キャット", dog="ドッグ", fish= "フィッシュ", speak="えいごをよんでください"}
--
...
...
local function callback(event)
    if not event.isError then
		...
		...
                local _target = event.message
                for i = 1, layer.v2t_grp.numChildren do
                    local child = layer.v2t_grp[i]
                    -- Simple string.sub() won't work for UTF-8 strings, use UTF-8 plugin
                    if string.find(v2tLib.Conv[child.name],  _target) then
                        print(child.name)
                        v2tLib.speak(v2tLib.Conv[child.name])
                        UI.v2t_store[child.name] = child
                        child.alpha = 1