Commit Graph

142 Commits

Author SHA1 Message Date
Narayan Kamath
9637198699 Minor changes to AudioTrack handling
Based on a discussion with the media folks.

Change-Id: I290cec062fcb53fccae1fd92387439448a54e81c
2011-07-05 15:46:53 +01:00
Narayan Kamath
bd2492e14e Expose the currently used engine to bundled apps.
This is required to fix a couple of niggles and annoyances
in the Settings app.

Change-Id: I0ad0c41744282b552e844ba9a2157cea74c64234
2011-06-27 18:35:47 +01:00
Narayan Kamath
4d03462b37 New API for TTS settings.
Engines must declare a <meta-data> attribute in their
manifest with name "android.speech.tts". This must reference
an XML resource as per
com.android.internal.R.styleable.TextToSpeechEngine.

Change-Id: I56a6b9f1a360174f98c9f39da901ade83d0f38a7
2011-06-21 10:28:30 +01:00
Narayan Kamath
edd12149f0 Merge "Don't enforce defaults any more in the TextToSpeech API." 2011-06-16 03:05:07 -07:00
Narayan Kamath
c3edf2a01a Don't enforce defaults any more in the TextToSpeech API.
This has been discussed in an email thread. This brings the
text to speech API in line with other android APIs.

The user can set default speech rates / languages and
engine preferences, which the API obeys BUT these can be
overriden by individual apps (much like intent.setComponent
and intent.setClassName can be used to launch a specific
handler for a given intent).

Also, all installed engines are enabled by default. The
user is shown the "data privacy" warning every time an
installed engine is set to the default.

Change-Id: I24f5f331b3a7cc7ce1a62962192e3a452bdca9d4
2011-06-16 10:31:45 +01:00
Narayan Kamath
9ee8154e59 Increase the visibility of SynthesisRequest
This makes it a lot easier for engine implementers
to test their engine. This is a dumb data object, and
contains no logic whatsoever.

Change-Id: I2a8bea134a8ff6b962508cfed67ea6085a682b23
2011-06-15 18:50:23 +01:00
Narayan Kamath
d0648ed060 Fix a bug in TextToSpeech.
Check that the requested engine is enabled.

Change-Id: I8436b0b7b7f441fe3473601fb9c46181e90750e0
2011-06-15 12:35:51 +01:00
Narayan Kamath
9a67f26184 Merge "A few TTS bug fixes" 2011-06-14 07:05:42 -07:00
Narayan Kamath
0e20fe5bab A few TTS bug fixes
(a) ensure that onInit is called exactly once per call to initTts().
(b) TtsEngines should never return an engine that is not installed.

Change-Id: Ic1ef63a9339e6d1050e3302445ca40d3ae481f61
2011-06-14 13:29:20 +01:00
Narayan Kamath
3f0363bb4b Deprecate setEngineByPackageName
This function does not let callers know when the TTS engine has
been initialized.

Change-Id: I17fcf3f95ad5bbdb9b787ba0846e6e63d424cd23
2011-06-14 12:28:45 +01:00
Narayan Kamath
d3ee2fa184 Refactor some of TextToSpeech
required to let the Settings code to the same logic
and not have to roll it's own.

Change-Id: I2766b8562c940182a2954555fb1854889c3ac91a
2011-06-10 16:33:28 +01:00
Narayan Kamath
a5084e6389 Merge "Don't hardcode the default engine." 2011-06-10 07:53:56 -07:00
Narayan Kamath
22302fb7ba Don't hardcode the default engine.
One point to note is that no TTS engine will be selected
by default if there are no system TTS engines.

Change-Id: I397061e3cf29b8a1c66e7864262b43621ef5100d
2011-06-10 15:29:06 +01:00
Narayan Kamath
abc63fbdda Some TTS fixes.
(a) Document the undocumented queue mode (mode == 2)
(b) intern strings to fix a bug in removeCallbacksAndMessages
(c) remove an unnecessarly lock object, change the field it
guarded to volatile.

Change-Id: If46bbfe2afb047b3ba5b3cb9a90c292656379ec1
2011-06-10 13:01:46 +01:00
Narayan Kamath
4924fe3867 Implement QUEUE_FLUSH and QUEUE_DESTROY addition modes.
Note that this change is slightly more flexible, it defines
a priority for each playback request. We needn't really throw
away synthesis requests from other apps. We could just play
them after higher priority ones (for e.g from talkback).

Change-Id: I6c7dd9abe4871e87da08d9aaa4c55225a69078e5
2011-06-09 16:42:16 +01:00
Narayan Kamath
e22b69a7de Make changes to the TTS api suggested by the API review.
This ended up making the implementation a lot cleaner
as well. See the bug listed below for some background.

bug:4553470
Change-Id: If16476a57e389c2f9b228f6548e426642d292b49
2011-06-08 16:46:00 +01:00
Narayan Kamath
8d1fc2403b Fix the threading behaviour of TTS audio requests.
All audio is played back on a separate thread.

Change-Id: I2bbb7b3140f6a04ef705cadb2bd1ae88951e3c48
2011-06-07 16:27:18 +01:00
Narayan Kamath
7a3af86dc0 Language loading / availablity should repsect defaults enforcement.
There is no point loading a language that will never be used.
It is in fact harmful, because the engine might load it and
then receive a request for the default voice and have to load
the default voice again.

Change-Id: I8082f28d15b6e325d6a39d439b66753711a2c244
2011-06-02 17:28:57 +01:00
Narayan Kamath
c90f1c815d Add a separate thread for writing to audiotracks.
Now, SynthesisRequest.audioAvailable( ) will not block
until all data has been written to the audiotrack.

Change-Id: Ie24c0b6873ae44659e88646fb7ef821750dc314e
2011-05-25 15:31:06 +01:00
Narayan Kamath
b956f37e37 Pass synthesis request params through to the TTS service.
Change-Id: I1ffd617d8dfa0814382643e3cf6b3ab7417c742a
2011-05-17 09:47:59 +01:00
Bjorn Bringert
4bbca889df Expose TTS engine API
This is a new API for writing text-to-speech engines.
The existing API for apps that use TTS remains the same,
with some minor additions.

Change-Id: Id577db449ae0e5baec40621d4a08387dbd755342
2011-04-27 08:25:24 +01:00
Narayan Kamath
53f6f95308 Fix onCompleteAudioAvailable
(a) Don't check that the audiotrack is initialized (will
not be true in static mode until the first write call)
(b) Block until it completes playing.

Change-Id: I50eb6cece00f3d12f3b75102d62014c360ac0346
2011-04-19 16:39:20 +01:00
Bjorn Bringert
a210e15c89 Merge "TTS: SynthesisRequest.error() instead of return value" 2011-04-19 03:06:13 -07:00
Bjorn Bringert
360eb168d6 TTS: SynthesisRequest.error() instead of return value
Change-Id: I02fe8ca1070a4e7c62ad30fd84c82bd6ecc2ecfa
2011-04-19 09:23:23 +01:00
Bjorn Bringert
fe6ea01602 Only return default TTS engines from TTS.getEngines()
Change-Id: I31a716a33c895d2a3349889046dce83c90704a2d
2011-04-18 20:27:40 +01:00
Bjorn Bringert
71e0b48077 Improve TTS engine audio buffer API
This adds two methods:
SynthesisRequest.getMaxBufferSize()
SynthesisRequest.completeAudioAvailable()

Change-Id: I1186eed45997ee9a7e51212c8d6706dd324ca949
2011-04-15 15:27:30 +01:00
Bjorn Bringert
50e657bb2d Add Java API for writing TTS engines
This removes the old non-public C++ API for TTS
engines and replaces it with a Java API.

The new API is still @hidden, until it has been approved.

Bug: 4148636
Change-Id: I7614ff788e11f897e87052f684f1b4938d539fb7
2011-04-15 10:04:31 +01:00
Joe Onorato
43a17654cf Remove the deprecated things from Config.java. These haven't been working since before 1.0.
Change-Id: Ic2e8fa68797ea9d486f4117f3d82c98233cdab1e
2011-04-07 19:23:05 -07:00
Mike LeBeau
216ce0f16e Add EXTRA_ORIGIN to RecognizerIntent.
This is for passing the http referer of a request, e.g., for speech
input from within a browser.

Bug: 4161306
Change-Id: I56fdb7466edd985aab6df8364be1f1619a11a00d
2011-04-05 16:38:24 -04:00
Mike LeBeau
bb7cf916b2 Support speech recognizer confidence values.
Pass speech recognizer confidence values in the SpeechRecognizer and
RecognizerIntent APIs through to the caller. This change defines new
API constants for keys to these values.

The corresponding change is being made to Google Voice Search, and should be
made to any other implementations.

Bug: 3267513
Bug: 4163206

Change-Id: I294553f2eb9eb3be21298b8434117c8c5309558d
2011-04-05 10:54:18 -04:00
Valentin Kravtsov
b18a047de5 am d35f9390: am 000466d7: am 125be9c8: Merge "Fixing a race condition in RecognitionService" into gingerbread
* commit 'd35f939010cb889d0e5d757f2e3f76c5b50b419a':
  Fixing a race condition in RecognitionService
2011-03-18 09:27:56 -07:00
Valentin Kravtsov
d35f939010 am 000466d7: am 125be9c8: Merge "Fixing a race condition in RecognitionService" into gingerbread
* commit '000466d79d33fa302c6c8d20d2db45faca7c31e0':
  Fixing a race condition in RecognitionService
2011-03-18 09:15:49 -07:00
Bjorn Bringert
2cad2cc153 Exception handling clean-up in TextToSpeech.java
This is just a code clean-up change. It should have no effects
on behavior.

- The exception clean-up code was copied in lots of places,
  added a restart() method for it.

- Use Log.e to print exception stack trace instead of doing
  it manually.

- Moved return statements outside finally-blocks. Having them
  in the finally-block makes no difference, but can be misleading.
  Also, Eclipse complains about it.

Change-Id: Ibfb18ca89d81d1fd8d212f29b6f8ab305b52ec49
2011-03-08 11:53:12 +00:00
Jean-Michel Trivi
708b47d1ec Fix bug 3511256 invalid TTS parameter cache size
The NB_CACHED_PARAMS is the number of cached parameters, not
 the size of the array for cached parameters.

Change-Id: I3d3053bbf247f3f89ae1ea07a931d33df7857a7c
2011-03-03 18:55:19 -08:00
Valentin Kravtsov
483701eb9f Fixing a race condition in RecognitionService
Bug #3458256

If an error occurs and simultaneously user cancels the recognition, here is what happens:
1. dispatchCancel() is called since the user requested cancel. It passes the first "if" successfully.

private void dispatchCancel(IRecognitionListener listener) {
       if (mCurrentCallback == null) {
           if (DBG) Log.d(TAG, "cancel called with no preceding startListening - ignoring");
       } else if (mCurrentCallback.mListener.asBinder() != listener.asBinder()) {
           Log.w(TAG, "cancel called by client who did not call startListening - ignoring");
       } else { // the correct state
           RecognitionService.this.onCancel(mCurrentCallback);
           mCurrentCallback = null;
           if (DBG) Log.d(TAG, "canceling - setting mCurrentCallback to null");
       }
   }

2. Error occurs in the app, which sets the mCurrentCallback to null:
       public void error(int error) throws RemoteException {
           mCurrentCallback = null;
           mListener.onError(error);
       }

3. the second "if" is reached in dispatchCancel()
4. boom

Change-Id: I54cdcc98b495d820a2caead1709d8dee968c461e
2011-03-02 10:16:28 +00:00
Jean-Michel Trivi
dc871fd870 resolved conflicts for merge of 3ebade5d to honeycomb-plus-aosp
Change-Id: Ifd5f88f75feeb2dad1131e6a262dff3b979bdf8d
2011-01-24 09:35:57 -08:00
Jean-Michel Trivi
1e13a02320 Bug 3365937 notify TTS initialization listener of binding errors
The creation of a TextToSpeech object causes the TTS service to
 start, and the initialization listener to be called when the
 service is connected. But the listener is never called when
 the service binding failed to be notified of this error.
The fix consists in checking the result of the bind to service
 operation, and notify the listener in case of an error.

More log was added in case speak() and synthesizeToFile() are
 called but the service is not known to have started.

Change-Id: I7dcc1fa44be31fee3177ec6215fca3306377b934
2011-01-20 17:25:48 -08:00
Jean-Michel Trivi
9011ec832d Fix bug 2084122: enable application control over text synth volume
This CL unhides two "keys" an application can use to specify for
 an utterance its playback volume and pan. Those two new keys
 use the same mechanism already in place for an application to
 specify stream type and utterance ID.

Change-Id: I020363487d7a0f471fb8d3ed739c561d2ab4b0a9
2011-01-11 13:42:44 -08:00
Jean-Michel Trivi
9d2d26af2e Add support in TTS for volume and panning control of the synth output
Add two new parameters that are used when synthesizing text and
 playing it back directly to control the volume and left-right
 panning of the output.
Panning is applied using a balance law, which is not energy-preserving
 but which doesn't lower the volume when not panning / panning to
 center (legacy behavior).

Reduced amount of logs, and removed spoken text.

In TextToSpeech.java: added convenience method to handle the setting
 of the cached synthesis parameters.

Change-Id: I235d3d3193283ccc1891e2065d43787e3f63304d
2011-01-05 16:24:30 -08:00
Mike LeBeau
19e353e722 am 0655b31d: am 12b82c8d: Merge "Unhide RecognizerResultsIntent. This API was reviewed for Froyo, but we didn\'t want to make it public then because it wasn\'t until our first Market release of Voice Search that the APIs would be in use by our app." into gingerbread
* commit '0655b31d758ce8fe054c98c6d288e424f2d273e2':
  Unhide RecognizerResultsIntent. This API was reviewed for Froyo, but we didn't want to make it public then because it wasn't until our first Market release of Voice Search that the APIs would be in use by our app.
2010-12-20 12:00:06 -08:00
Mike LeBeau
52af3a4f9a Unhide RecognizerResultsIntent. This API was
reviewed for Froyo, but we didn't want to make it
public then because it wasn't until our first
Market release of Voice Search that the APIs would
be in use by our app.

http://b/3135351

Change-Id: I49053717cac08e3976c22e3a105139b6755aadb8
2010-12-20 10:50:31 -05:00
Mike LeBeau
b30023caba Add new EXTRA_WEB_SEARCH_ONLY to RecognizerIntent API. This can be used to
avoid triggering any non-web-search actions from the speech recognizer
(such as Voice Actions in the Google implementation). The browser will set
this to true to avoid triggering non-web-search actions when speech
recognition is requested from the browser.

Change-Id: I9b410ef8696e12f22dbad325b367f0f187a2dce8
http://b/3289997
http://b/3176717
2010-12-16 14:41:46 -05:00
Ben Dodson
4e8620f868 Updated documentation for upcoming fix for @code tags
Change-Id: Id7b163179132b9cf180afecb4e9e10ee39bcd415
2010-08-26 14:02:20 -07:00
Jean-Michel Trivi
4a60d61887 Fix NPE in TextToSpeech with setLanguage(null)
getLanguage() can return null, and pass it to setLanguage()
  in TextToSpeech.initTts()

Change-Id: I8046e94959404bd63b0a90bcc2dbf4018f77c110
2010-07-26 16:11:58 -07:00
Valentin Kravtsov
2b0c7ab689 Fixing: RecognitionService logcat spam "cancel called..."
Bug fix for: http://b/issue?id=2647644

RecognitionService logcat spam "cancel called with no preceding startListening - ignoring"

Change-Id: I1da8b4d40406929ed0225d40cfac629507e71c7e
2010-05-04 20:53:52 +01:00
Valentin Kravtsov
1c3cca0abe bugfix for: OOM error while doing voice search repeatedly
fix for: http://b/issue?id=2599931

Change-Id: Ic27d9eb8b29afa99787e469d9248c20f7d2988de
2010-04-22 18:55:54 +01:00
Charles Chen
6df44727d0 Unhiding TTS API constants and methods needed for TTS plugin support.
This is a fix for bug #2548048

Change-Id: Ieb60979098c1d2e82618204882bd523d271a8784
2010-04-02 13:39:53 -07:00
Charles Chen
ddc2eb8ee3 Merge "Fix for bug 2564771 - pitch setting between apps can interfere with one another." into froyo 2010-04-01 17:56:47 -07:00
Charles Chen
1a2712ce2a Fix for bug 2564771 - pitch setting between apps can
interfere with one another.

Root cause was not caching all the params that were needed.
This change fixes that bug as well as related bugs for remembering
the default engine and for making sure that the right engine is
loaded when checking for language availability.

Change-Id: I2a76da8faec8112036e68d27539db444c53a1509
2010-04-01 17:39:15 -07:00
Jean-Michel Trivi
2a5d9f9b57 Fix bug 2553592 API REVIEW: android.speech
Change 1 of 4
Notes from API Council review:
Rename RecognitionManager to SpeechRecognizer

Change-Id: I892c0d714d928d5e31575c72b6a36281fc4c7a8a
2010-03-30 11:14:55 -07:00