[android-developers] Re: Speech recognition: prevent or automatically handle No matches found dialog

2010-05-18 Thread pac
Thanks for your information.

I ended up having the app sleep for several seconds and then do a
finishActivity() because if nothing happened by then, some error must
have occurred.

On Apr 20, 2:28 pm, Dianne Hackborn hack...@android.com wrote:
 Sorry, the current API does not provide this kind of control.



 On Tue, Apr 20, 2010 at 10:45 AM, pac patty.c...@gmail.com wrote:
  My speech recognition app needs to work without human intervention, so
  the situations where the No speech heard or the No matches found
  dialogs come up and require a button press are a problem.

  Is there a way to prevent this dialog from displaying?

  Is there a way to programming perform the button click?

  Is there a way to programmatically close the dialog?

  This is how I'm firing the RecognizerIntent:

         Intent intent= new
  Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
         intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                         RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
         intent.putExtra(RecognizerIntent.EXTRA_PROMPT, Speech
  recognition demo);
         startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: AudioRecord creates a stereo file instead of a mono file.

2010-05-18 Thread pac
I must have just gotten the parameters wrong.  I can create a mono
file.  But I used AudioFormat.CHANNEL_IN_MONO, not
AudioFormat.CHANNEL_CONFIGURATION_MONO.

On May 1, 9:41 am, niko20 nikolatesl...@yahoo.com wrote:
 Yes its a bug, sounds like the WAV header is wrong. You'll have to
 hack at that source to fix it..

 On Apr 29, 5:51 pm, pac patty.c...@gmail.com wrote:



  I'm developing with Android 2.1 on a Nexus One with firmware 2.1
  update 1.

  I'm using the RehearsalAudioRecorder class from here:

 http://rehearsalassist.svn.sourceforge.net/viewvc/rehearsalassist/and...

          public RehearsalAudioRecorder(boolean uncompressed, int audioSource,
  int sampleRate, int channelConfig,
                          int audioFormat)
          {
                  try
                  {
                          rUncompressed = uncompressed;
                          if (rUncompressed)
                          { // RECORDING_UNCOMPRESSED
                                  if (audioFormat == 
  AudioFormat.ENCODING_PCM_16BIT)
                                  {
                                          bSamples = 16;
                                  }
                                  else
                                  {
                                          bSamples = 8;
                                  }

                                  if (channelConfig == 
  AudioFormat.CHANNEL_CONFIGURATION_MONO)
                                  {
                                          nChannels = 1;
                                  }
                                  else
                                  {
                                          nChannels = 2;
                                  }

                                  aSource = audioSource;
                                  sRate   = sampleRate;
                                  aFormat = audioFormat;

                                  framePeriod = sampleRate * TIMER_INTERVAL / 
  1000;
                                  bufferSize = framePeriod * 2 * bSamples * 
  nChannels / 8;
                                  if (bufferSize  
  AudioRecord.getMinBufferSize(sampleRate,
  channelConfig, audioFormat))
                                  { // Check to make sure buffer size is not 
  smaller than the
  smallest allowed one
                                          bufferSize = 
  AudioRecord.getMinBufferSize(sampleRate,
  channelConfig, audioFormat);

                                          // Set frame period and timer 
  interval accordingly
                                          framePeriod = bufferSize / ( 2 * 
  bSamples * nChannels / 8 );
                                          
  Log.w(RehearsalAudioRecorder.class.getName(), Increasing buffer
  size to  + Integer.toString(bufferSize));
                                  }

                                  aRecorder = new AudioRecord(audioSource, 
  sampleRate,
  channelConfig, audioFormat, bufferSize);
                                  if (aRecorder.getState() != 
  AudioRecord.STATE_INITIALIZED)
                                          throw new Exception(AudioRecord 
  initialization failed);
  //                              
  aRecorder.setRecordPositionUpdateListener(updateListener);
                                  
  aRecorder.setPositionNotificationPeriod(framePeriod);
                          } else
                          { // RECORDING_COMPRESSED
                                  mRecorder = new MediaRecorder();
                                  
  mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                                  
  mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
                                  
  mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
                          }
                          cAmplitude = 0;
                          fPath = null;
                          state = State.INITIALIZING;
                  } catch (Exception e)
                  {
                          if (e.getMessage() != null)
                          {
                                  
  Log.e(RehearsalAudioRecorder.class.getName(), e.getMessage());
                          }
                          else
                          {
                                  
  Log.e(RehearsalAudioRecorder.class.getName(), Unknown error
  occurred while initializing recording);
                          }
                          state = State.ERROR;
                  }
          }

  Here's how I'm instantiating it:
                          RehearsalAudioRecorder recorder = new 
  RehearsalAudioRecorder(
                                                  
  RehearsalAudioRecorder.RECORDING_UNCOMPRESSED,
                                                  
  MediaRecorder.AudioSource.MIC,
                                                  16000

[android-developers] Re: AudioRecord: onPeriodicNotification and onMarkerReached are not called

2010-05-18 Thread pac
Thanks for the information.  I gave up on the listener.  I'm using a
handler, and my recorder class is calling back to the activity
whenever a buffer is ready to be processed.  I'm having issues with
that, but I posted about it elsewhere.

On May 14, 11:45 am, HeHe cnm...@gmail.com wrote:
 initially i use those callbacks both of AudioRecorder and AudioTrack.
 then i found them not as reliable as i had thought, so later i removed
 my dependency on them. then, i was surprised to learn that without
 using the callbacks both my audio recording and playback code
 performed as well if not much better ^_^

 On May 14, 9:29 am, pac patty.c...@gmail.com wrote:

  Has anyone gotten this working?

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group 
  athttp://groups.google.com/group/android-developers?hl=en

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Handler: UI gets updated all at once at the end

2010-05-17 Thread pac
I'm using AudioRecord in a separate class, and I have it read a buffer
in a loop and callback to the main activity with the buffer.

The activity processes the buffer and calculates a number that I want
to update the UI with (I'm using animation to move a button).  What
I'm finding is that first all the buffers are getting processed, and
then after that's done, the handler is apparently handling all the
messages and doing all the UI updates one after the other.

Perhaps this is working as designed because I think the handler
message processing occurs after the other work is done.  If this is
true, what can I do to process a buffer and then immediately update
the UI (and do that for each buffer)?

Here's a snippet of the recording part.  In the constructor, I'm
passing in a reference to the activity so I can callback to it.

Recorder(myActivity act)
{
super();
this.setFrequency(frequency);
this.setChannelConfiguration(AudioFormat.CHANNEL_IN_MONO);
this.setPaused(false);
this.act = act;
}

AudioRecord recordInstance = new AudioRecord(
MediaRecorder.AudioSource.MIC,
this.getFrequency(),
this.getChannelConfiguration(),
this.getAudioEncoding(),
bufferSize);

recordInstance.startRecording();

buffer = new byte[bufferSize];

while (this.isRecording) {
// Are we paused?
synchronized(mutex)
{
if (this.isPaused)
{
try
{
mutex.wait(250);
}
catch 
(InterruptedException e)
{
throw new 
IllegalStateException(Wait() interrupted!,e);
}
continue;
}
}

bufferRead = 
recordInstance.read(buffer, 0, bufferSize);

if (bufferRead == 
AudioRecord.ERROR_INVALID_OPERATION)
{
throw new 
IllegalStateException(read() returned
AudioRecord.ERROR_INVALID_OPERATION);
}
else if (bufferRead == 
AudioRecord.ERROR_BAD_VALUE)
{
throw new 
IllegalStateException(read() returned
AudioRecord.ERROR_BAD_VALUE);
}
else if (bufferRead == 
AudioRecord.ERROR_INVALID_OPERATION)
{
throw new 
IllegalStateException(read() returned
AudioRecord.ERROR_INVALID_OPERATION);
}

// Write buffer to file
try
{
fWriter.write(buffer);
}
catch (Exception e)
{
Log.d(Recorder.class.getName(), 
e.getMessage());
}

payloadSize += buffer.length;

// Tell activity we have a buffer to 
process
act.startLongRunningOperation();
}

Here's what I have in the activity (I instantiate Recorder in
onCreate()):

// Need handler for callbacks to the UI thread
final Handler mHandler = new Handler();

// Create runnable for posting
final Runnable mUpdateResults = new Runnable() {
public void run() {
updateResultsInUi();
}
};

   protected void startLongRunningOperation()
{
 // Fire off a thread to do some work that we shouldn't do
directly in the UI thread
Thread t = new Thread() {
public void run() {
mHandler.postAtFrontOfQueue(mUpdateResults);
}
 

[android-developers] Re: AudioRecord: onPeriodicNotification and onMarkerReached are not called

2010-05-14 Thread pac
Has anyone gotten this working?


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to get activity to restart every time the app is launched from the command line

2010-05-13 Thread pac
Device: Nexus One
Firmware: 2.1 update 1
Platform 2.1, API: 7

I have seen it mentioned before that there's a difference between
installing an app via Eclipse and via adb, but I need more
clarification.

I have an app that starts a voice recognition activity in the main
activity's onStart() method..  I'm planning to run this app from a
Nexus One connected to a laptop via USB.  I want this app to launch
perhaps 100 times, each time restarting the voice recognition
activity.

When I install the app onto the Nexus One via Eclipse, I notice this
behavior:
- when the app is launched from the command line via adb shell am
start -a android.intent.action.MAIN -n com.voice/com.voice.VoiceSearch
$1, the app runs with the voice recognition activity restarting each
time.  This is the behavior I want.
- I also notice that after the app has run, I hit Home, then click on
the app from the screen, the app will be in its last state, and the
voice recognition activity will not restart.  I specified
finishOnTaskLaunch=true in the manifest, so I thought the voice
recognition activity would restart.

When I package an app as per instructions and install it onto the
device via adb install, I get this behavior:
- when the app is launched from the command line, the voice
recognition app will run the first time, but subsequent launches do
not restart the voice recognition activity.   The voice recognition
activity just stays in its last state.   I get the following message:
Warning: Activity not started, its current task has been brought to
the front

- I also notice that after the app has run, I hit Home, then click on
the app from the screen, the app will restart the voice recognition
activity.  By the way, this happens whether or not I have
finishOnTaskLaunch=true set in the manifest or not.

What do I need to do so that I can launch the app from the command
line via adb lots of times with the voice recognition activity
restarting each time?

I call this from the main activity's onStart():

private void startVoiceRecognitionActivity() {
Intent intent= new
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, Say something!);
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
waitForResults();
}

Manifest:
?xml version=1.0 encoding=utf-8?
manifest xmlns:android=http://schemas.android.com/apk/res/android;
  package=com.audience.android.voice
  android:versionCode=1
  android:versionName=1.0
application android:icon=@drawable/icon android:label=@string/
app_name
activity android:name=.VoiceSearch
  android:finishOnTaskLaunch=true
  android:clearTaskOnLaunch=true
  android:label=@string/app_name
intent-filter
action android:name=android.intent.action.MAIN /
category
android:name=android.intent.category.LAUNCHER /
/intent-filter
/activity
/application
uses-sdk android:minSdkVersion=7 /
uses-permission android:name=android.permission.INTERNET /

/manifest

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] AudioRecord: onPeriodicNotification and onMarkerReached are not called

2010-05-13 Thread pac
I've seen posts regarding problems with the AudioRecord
OnRecordPositionUpdateListener, but I haven't seen any real answers.

I'm using AudioRecord to record from the mic, and I want to get the
input from the mic periodically so I can check sound levels and update
a meter.  I set up the listener like this:

private OnRecordPositionUpdateListener mRecordListener = new
AudioRecord.OnRecordPositionUpdateListener()
{
public void onPeriodicNotification(AudioRecord recorder) {
if 
(recorder.getRecordingState()!=aRecorder.RECORDSTATE_STOPPED)
{
mAudioBuffer = new short[8000];
mSamplesRead = recorder.read(mAudioBuffer, 0, 
8000);
if (mSamplesRead  0)
{
// do something
}
}
}

public void onMarkerReached(AudioRecord recorder)
{
if 
(recorder.getRecordingState()!=aRecorder.RECORDSTATE_STOPPED)
{
mAudioBuffer = new short[8000];
mSamplesRead = recorder.read(mAudioBuffer, 0, 
8000);
}
}
};

I instantiate the AudioRecord object like this:

// audioSource = MediaRecorder.AudioSource.MIC
// sampleRate = 16000
   // channelConfig = AudioFormat.CHANNEL_IN_MONO
   // audioFormat = AudioFormat.ENCODING_PCM_16BIT
   // bufferSize = 409600

aRecorder = new AudioRecord(audioSource, sampleRate, 
channelConfig,
audioFormat, bufferSize);
if (aRecorder.getState() != 
AudioRecord.STATE_INITIALIZED)
throw new Exception(AudioRecord initialization 
failed);

aRecorder.setRecordPositionUpdateListener(mRecordListener);
aRecorder.setPositionNotificationPeriod(400);
aRecorder.setNotificationMarkerPosition(400);

What happens is that onMarkerReached gets called once, after the
recorder is released, so that's not very useful.

Do I need to change the marker position and notification period?  Is
the listener working?  Is there another way to accomplish periodically
getting the mic input?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] AudioRecord delay in recording

2010-05-05 Thread pac
I'm using a class that uses AudioRecord.

RehearsalAudioRecorder recorder = new 
RehearsalAudioRecorder(

RehearsalAudioRecorder.RECORDING_UNCOMPRESSED,
MediaRecorder.AudioSource.MIC,
16000,
AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT);

The RehearsalAudioRecorder constructor instantiates an AudioRecord:

  aRecorder = new AudioRecord(audioSource,
sampleRate, channelConfig, audioFormat, bufferSize);

I'm creating a .wav file on the SD card.

I'm experiencing a 5 second delay in the recording; I play back the
file, and the recording starts about 5 seconds after I started
speaking.

I did some measurements with System.currentTimeMillis(), and I
measured the following:

buffer size: 204800 bytes
constructor: 17 ms
write the file header: 6 ms
AudioRecord.startRecording(): 483 ms
AudioRecord.read(): 6268 ms

There's correspondingly less delay when I use a smaller buffer:

buffer size: 81920 bytes
constructor: 16 ms
write the file header: 5 ms
AudioRecord.startRecording(): 486 ms
AudioRecord.read(): 2427 ms

Does anyone have any suggestions as to how to reduce the delay?  It's
still unacceptable to have a few seconds delay.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] AudioRecord creates a stereo file instead of a mono file.

2010-04-29 Thread pac
I'm developing with Android 2.1 on a Nexus One with firmware 2.1
update 1.

I'm using the RehearsalAudioRecorder class from here:

http://rehearsalassist.svn.sourceforge.net/viewvc/rehearsalassist/android/trunk/src/urbanstew/RehearsalAssistant/RehearsalAudioRecorder.java?view=markup

public RehearsalAudioRecorder(boolean uncompressed, int audioSource,
int sampleRate, int channelConfig,
int audioFormat)
{
try
{
rUncompressed = uncompressed;
if (rUncompressed)
{ // RECORDING_UNCOMPRESSED
if (audioFormat == 
AudioFormat.ENCODING_PCM_16BIT)
{
bSamples = 16;
}
else
{
bSamples = 8;
}

if (channelConfig == 
AudioFormat.CHANNEL_CONFIGURATION_MONO)
{
nChannels = 1;
}
else
{
nChannels = 2;
}

aSource = audioSource;
sRate   = sampleRate;
aFormat = audioFormat;

framePeriod = sampleRate * TIMER_INTERVAL / 
1000;
bufferSize = framePeriod * 2 * bSamples * 
nChannels / 8;
if (bufferSize  
AudioRecord.getMinBufferSize(sampleRate,
channelConfig, audioFormat))
{ // Check to make sure buffer size is not 
smaller than the
smallest allowed one
bufferSize = 
AudioRecord.getMinBufferSize(sampleRate,
channelConfig, audioFormat);

// Set frame period and timer interval 
accordingly
framePeriod = bufferSize / ( 2 * 
bSamples * nChannels / 8 );

Log.w(RehearsalAudioRecorder.class.getName(), Increasing buffer
size to  + Integer.toString(bufferSize));
}

aRecorder = new AudioRecord(audioSource, 
sampleRate,
channelConfig, audioFormat, bufferSize);
if (aRecorder.getState() != 
AudioRecord.STATE_INITIALIZED)
throw new Exception(AudioRecord 
initialization failed);
//  
aRecorder.setRecordPositionUpdateListener(updateListener);

aRecorder.setPositionNotificationPeriod(framePeriod);
} else
{ // RECORDING_COMPRESSED
mRecorder = new MediaRecorder();

mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);

mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);

mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
}
cAmplitude = 0;
fPath = null;
state = State.INITIALIZING;
} catch (Exception e)
{
if (e.getMessage() != null)
{
Log.e(RehearsalAudioRecorder.class.getName(), 
e.getMessage());
}
else
{
Log.e(RehearsalAudioRecorder.class.getName(), 
Unknown error
occurred while initializing recording);
}
state = State.ERROR;
}
}

Here's how I'm instantiating it:
RehearsalAudioRecorder recorder = new 
RehearsalAudioRecorder(

RehearsalAudioRecorder.RECORDING_UNCOMPRESSED,
MediaRecorder.AudioSource.MIC,
16000,
AudioFormat.CHANNEL_IN_FRONT,

AudioFormat.CHANNEL_CONFIGURATION_MONO);

I write a .wav file to the SD card.  I specified mono, and I checked
that CHANNEL_CONFIGURATION_MONO is indeed set in the AudioRecord
object.  But when I try to play the file, it's treated as if it's
stereo, and voices sound like chipmunks.  Apparently the header
information is wrong.  For instance, I open the .wav file in Audacity,
and Audacity says it's stereo.

Is this a bug?  What can I do?

-- 

[android-developers] Not getting RecognizerIntent result codes

2010-04-22 Thread pac
I want to get the RecognizerIntent result codes such as
RESULT_SERVER_ERROR because I want to distinguish between the cases
where the speech wasn't understood or no matches were found and the
cases where recognition didn't occur because of connection or server
problems.

When onActivityResult() executes, however, the result code is either
RESULT_OK or 0.  I never catch any of the various RecognizerIntent
result codes.  What do I need to do?

Here's my code:

  private void startVoiceRecognitionActivity() {
Intent intent= new
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, Say something!);
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
}

protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == VOICE_RECOGNITION_REQUEST_CODE 
resultCode == RESULT_OK) {
  // do stuff
}
else if (requestCode == VOICE_RECOGNITION_REQUEST_CODE 
resultCode != RESULT_OK) {

// Figure out the error
String err = ;
switch (resultCode) {
case (RecognizerIntent.RESULT_AUDIO_ERROR):
err = Audio error;
break;
case (RecognizerIntent.RESULT_CLIENT_ERROR):
err = Client error;
break;
case (RecognizerIntent.RESULT_NETWORK_ERROR):
err = Network error;
break;
case (RecognizerIntent.RESULT_NO_MATCH):
err = No match;
break;
case (RecognizerIntent.RESULT_SERVER_ERROR):
err = Server error;
break;
}
   }
super.onActivityResult(requestCode, resultCode, data);
}

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Speech recognition: prevent or automatically handle No matches found dialog

2010-04-20 Thread pac
My speech recognition app needs to work without human intervention, so
the situations where the No speech heard or the No matches found
dialogs come up and require a button press are a problem.

Is there a way to prevent this dialog from displaying?

Is there a way to programming perform the button click?

Is there a way to programmatically close the dialog?

This is how I'm firing the RecognizerIntent:

Intent intent= new
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, Speech
recognition demo);
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] RecognizerIntent speech prompt not getting focus upon activity relaunch

2010-04-19 Thread pac
I used VoiceRecognition.java as a starting point for my app.  But
instead of having a button that when clicked calls
startVoiceRecognitionActivity() to fire a RecognizerIntent to start a
voice recognition activity, I called startVoiceRecognitionActivity
directly from onCreate().

I need to launch the app from a pc via adb shell am start -a
android.intent.action.MAIN -n my app $1, and I need to launch the
app multiple times.  If the activity is already running, and I use the
adb command to launch the app, the view displays, but the speech
prompt does not display.

I noticed an issue related to this has been raised, but I don't know
if it's been resolved.
http://code.google.com/p/android/issues/detail?id=2914

So is it a focus issue?  The RecognizerIntent is getting fired, and
it's just not getting the focus?  What do I need to do to force it to
have the focus?

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Begin voice recognition
startVoiceRecognitionActivity();

// Inflate our UI from its XML layout description.
setContentView(R.layout.voice_recognition);

// List of recognized words
mList = (ListView) findViewById(R.id.list);
}

private void startVoiceRecognitionActivity() {
Intent intent= new
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, What are you
looking for?);
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
}

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en