Page 1 of 1

How to recognize a voice?

Posted: Tue May 10, 2022 5:58 pm
by liveCode
I'm trying to make an app on my phone that recognizes sound
What I want to do is let the user talk and then the app will recognize what he said and do what the user wanted
So how can I detect sound in my app?

Re: How to recognize a voice?

Posted: Tue May 10, 2022 6:27 pm
by Klaus
Currently there is no "speech recognition" in LC, only the opposite -> text to speech

Re: How to recognize a voice?

Posted: Tue May 10, 2022 7:33 pm
by FourthWorld
Popular answer: you can use LC Builder to tap into OS APIs for things LC doesn't currently provide a scripting interface for.

Unpopular answer: I do not encourage use of any always-on microphone connected to the internet. Few consumers are aware of the implications, and unwittingly have their private conversations listened to by strangers thousands of miles away. I used to use voice navigation until I listened to the recordings the device was collecting on the provider's servers. Turned it off, never looked back.


Background:

Apple Belatedly Confirms Bug Which Collected Audio Recordings From iPhone Users

Excerpt:
“I listened to hundreds of recordings every day, from various Apple devices,” said le Bonniec. “These recordings were often taken outside of any activation of Siri, eg in the context of an actual intention from the user to activate it for a request. These processings were made without users being aware of it, and were gathered into datasets to correct the transcription of the recording made by the device.”
https://www.forbes.com/sites/gordonkell ... 06264193b7


As Voice Recognition Technology Market Surges, Organizations Face Privacy and Cybersecurity Concerns
https://www.natlawreview.com/article/vo ... rivacy-and


Report Reveals How Amazon Uses Alexa Voice Data for Targeted Ads
https://www.pcmag.com/news/a-new-report ... rgeted-ads


How to locate and delete voice commands on Google Assistant, Siri, and Alexa
https://knowtechie.com/how-to-delete-vo ... iri-alexa/


A possible exception may be the open source Mycroft AI project, when self-hosted (though few consumers want to run their own server)
https://mycroft.ai


Bonus: Anything from Cory Doctorow, eg:
https://onezero.medium.com/how-to-destr ... 35e6744d59

Re: How to recognize a voice?

Posted: Wed May 11, 2022 1:39 am
by stam
Richard, thanks for that last link to Cory Doctorow - very long but quite an interesting read...

Re: How to recognize a voice?

Posted: Wed May 11, 2022 2:47 am
by FourthWorld
stam wrote:
Wed May 11, 2022 1:39 am
Richard, thanks for that last link to Cory Doctorow - very long but quite an interesting read...
Glad you found it helpful. He was a keynote speaker at the SoCal Linux Expo a few years ago. Very eye-opening talk. Been following him ever since. His Twitter feed is worthwhile.

Re: How to recognize a voice?

Posted: Wed May 11, 2022 10:07 am
by scott_morrow
I don't know your exact use case and this could be quite ugly from a UI standpoint but, might one possible "work around" be to create a native UITextField and use the built-in speech to text feature provided to the field by the OS. Then the app could query the field.

Re: How to recognize a voice?

Posted: Wed May 11, 2022 2:22 pm
by liveCode
So can anyone direct me more how do I do that?

Re: How to recognize a voice?

Posted: Thu May 12, 2022 9:15 am
by scott_morrow
"How to do it" is a particularly reasonable question in this case since looking up "field" in the dictionary doesn't point to mobileControlCreate, mobileControlSet or mobileControlGet(). While it does show the native field Widget objects, and the Android one does seems pretty comprehensive, neither of them point to mobileControlCreate, mobileControlSet or mobileControlGet() either.

LiveCode has a lesson for creating native mobile text fields:
https://lessons.livecode.com/m/4069/l/2 ... -on-mobile

Below is a brief overview.

To create a native field in iOS or Android use the command: mobileControlCreate. There are two kinds of mobile fields.
mobileControlCreate "input", "YourFieldName" -- this field allows a single line
mobileControlCreate "multiline", "YourFieldName" -- this field allows multiple lines

To set properties of the field look up the command: mobileControlSet
examples:
mobileControlSet "YourFieldName", "visible", true
mobileControlSet "YourFieldName", "rect", "20,20,200,50"

To get the content of the field use the function: mobileControlGet()
put mobileControlGet("YourFieldName", "unicodeText") into tUnicodeText

In order to get the dictation to work the user will need to tap the microphone icon that comes up with the mobile keyboard once the field is active.
This field object is native to iOS and Android, so it cannot be used in the IDE or desktop standalone apps. Sadly, you will also need to keep from triggering code which touches these "mobile only" commands and functions when you are not running on mobile because they will cause a script error outside of a mobile OS. So something like:

if the environment is "mobile" then
mobileControlCreate "input", "YourFieldName"
mobileControlSet "YourFieldName", "rect", "20,20,200,50"
end if