小米最新开发版版本号:android

来源:百度文库 编辑:偶看新闻 时间:2024/04/26 14:23:12
How can I integrate speech recognition with my camera app? up vote 1 down vote favorite share [fb] share [tw]

I am trying to integrate speech recognition to my camera app, more specifically I want my camera to open up and you click a button "Listen" and it listens for the word "snap" and then it takes a picture. I have a button on the app already, it is just adding the voice portion to it. How do you get it to check for specfic words?

android camera speech-recognition voice link|improve this question asked Nov 19 at 3:12tjr2010
704
44% accept rate
feedback

3 Answers

activeoldestvotes up vote 0 down vote

Refer http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/VoiceRecognition.htmlIt shows how to add Voice Recognition to your app.http://developer.android.com/reference/android/speech/package-summary.htmlThis package is useful for a reference too.

link|improve this answer answered Nov 19 at 3:16om252345
658411
feedback up vote 0 down vote

This shows a complete usage of TTS and Speech Recognition

https://github.com/gmilette/Say-the-Magic-Word-

Also you need the following:

A simple way to match is to use this loop:

protected void receiveWhatWasHeard(List heard,
        )
{
    WordDictionary command = new WordDictionary("Add");
    for (String said : heard)
    {
        if (command.isIn(said.split("\\s")))
        {
            Log.d(TAG, "heard add");
        }
    }
}

and this class:

public class WordDictionary
{
    private Set words;

    public WordDictionary(String... wordsIn)
    {
        this(Arrays.asList(wordsIn));
    }

    public WordDictionary(List wordsIn)
    {
        words = new LinkedHashSet(wordsIn);
    }

    public Set getWords()
    {
        return words;
    }

    public boolean isIn(String word)
    {
        return words.contains(word);
    }

    public boolean isIn(String [] wordsIn)
    {
        boolean wordIn = false;
        for (String word : wordsIn)
        {
            if (isIn(word))
            {
                wordIn = true;
                break;
            }
        }
        return wordIn;
    }

}

And your activity needs this:

@Override
    protected void
            onActivityResult(int requestCode, int resultCode, Intent data)
    {
        if (requestCode == VOICE_RECOGNITION_REQUEST_CODE)
        {
            if (resultCode == RESULT_OK)
            {
                List heard =
                        data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                for (int i = 0; i < heard.size(); i++)
                {
                    Log.d(TAG, i + ": " + heard.get(i));
                }
                receiveWhatWasHeard(heard);
            } else
            {
//fail
            }
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
link|improve this answer answered Nov 19 at 14:37gregm
1,0571923

i tried to import the app you had inside and I got errors mind giving me help? – tjr2010 Nov 20 at 6:26
which app and what errors? – gregm Nov 23 at 19:30 Was this post useful to you?      up vote 0 down vote

To actually take the photo once you get the signal that the user has said 'Snap' you have to implement a replacement for the Camera app. You can look at the Camera preview sample app (in API Demos / graphics) to see how to show the preview image. And the Camera class overview has detailed information on how to actually capture the image.

link|improve this answer answered Nov 19 at 17:54jonawebb
1
feedback

Android

32 mins ago - Pyrodante

Android For Life

9 hours ago - Venky
Speech Recognition for Searching FilesVoice Recognition Software For DevelopersHow do you efficiently create a grammar file for speech recognition given a large list of words?Usability: speech recognition versus keypadHow do I parameterize android speech recognition? android.speech.action.RECOGNIZE_SPEECH does not do anythingSpeech Recognition & ProgrammingVoice recognition on android with recorded sound clip?Training speech recognition softwareContinuous Speech Recognition AndroidVoice recognition with androidcan anyone give me a sample to record and recognize voice for iphone?Prototype based on speech recognitionSpeech recognition language modelVoice Activity Detection in AndroidSpeech Recognition can be done through web Browser…?Custom grammar for speech recognitionSpeech analyze / verification when reading a scriptWidget that calls speech recognition appProgrammatically accept credit cards over the telephone with voice + telephony API (text-to-speech and speech-to-text) like Twilio?Saving the audio file when using Android's speech recognitionSpeech recognition: Hindi or Gujarti?Voice Recognition Commands AndroidProblem in Pocketsphinx demo on Androidhow to determine whether speech recognition activity is running or notWhere do I get started when trying to add voice activation to my camera? question feed about | faq | new blog | chat | data | podcast | shop | legal | advertising info | mobile | contact us | feedback ■ stackoverflow.com  ■ api/apps  ■ careers  ■ serverfault.com  ■ superuser.com  ■ meta  ■ area 51  ■ webapps  ■ gaming  ■ ubuntu  ■ webmasters  ■ cooking  ■ game development  ■ math  ■ photography  ■ stats  ■ tex  ■ english  ■ theoretical cs  ■ programmers  ■ unix  ■ apple  ■ wordpress  ■ physics  ■ home improvement  ■ gis  ■ electronics  ■ android  ■ security  ■ bicycles  ■ dba  ■ drupal  ■ sharepoint  rev 2011.12.13.1 site design / logo ? 2011 stack exchange inc; user contributions licensed under cc-wiki with attribution required