Commit Graph

275 Commits

Author SHA1 Message Date
Niels Egberts
c9bd275db5 Merge "Fix checks for audio format." 2015-12-09 11:42:36 +00:00
Niels Egberts
9b2b2f5090 Fix checks for audio format.
Change-Id: I43e9a94f8ddd46f72d24e06d72702f354bbeae46
2015-12-08 14:57:48 +00:00
Neil Fuller
568f4de11a Merge "Fix @code escapes" 2015-12-03 09:44:01 +00:00
Neil Fuller
71fbb81b14 Fix @code escapes
The body of {@code} must not be HTML escaped. This is one of
several changes that fix the source in conjunction with a
doclava fix.

Bug: 25757239
Change-Id: Ib38a0fa2dd2a3d68e467f78a812071e763d7e881
2015-12-02 14:24:11 +00:00
Niels Egberts
453c13f771 Small refactoring for FileSynthesisCallback.
Removed unused callerIdentity member and removed null checks
for the dispatcher.

Change-Id: I2983f5d48a7a593bc998ba4e033f1e815fa61819
2015-11-30 14:02:08 +00:00
Niels Egberts
5fd28893f2 Fix docs build failure.
Change-Id: If8d215f34a48e0c61aec0d35f10f1bfd633a4254
2015-11-23 15:39:21 +00:00
Niels Egberts
a24b50bee1 Restrict audioformat to 8bit, 16bit or float PCM with an annotation and
a warning.

TextToSpeech.synthesizeToFile has only ever worked with 8bit and 16bit
PCM. In case of float PCM an invalid file would be generated and in case
of other encodings the TTS engine would crash.

Also add more annotations to SynthesisCallback.

Change-Id: I1c44a44509e9b53bb2e1b0f2044b1a5919875e1c
2015-11-23 10:15:39 +00:00
Niels Egberts
54545f7e65 NPE occured when trying to parcel voice features.
The default features member should be an empty list instead of null.

Bug: 22404239
Change-Id: Ia39982f17fd3b3cd0f3556435170aed2fac14fb8
2015-08-05 15:48:26 +01:00
Niels Egberts
992ea1553c Fix crash with engines that don't override getVoices().
The name of the voices was not normalized in getVoices(), therefore if
you use getDefaultVoiceName, that name possibly doesn't appear in
getVoices(). The framework would then run into a NullPointerException.

This was caught by the cts tests. Also added a few more log statements.

BUG: 22115315
Change-Id: I51404ddcd1bc10dd3e1ddaac410cfa9873bf1438
2015-06-26 16:25:37 +01:00
Narayan Kamath
b39dfe87b8 Delete android.speech.srec.*
This code had an undeclared dependency on libsrec_jni which
we no longer build.

bug: 21855957
Change-Id: Ie00645960b18aaa2a7d944a2ad31ff57e0b0b2ba
2015-06-16 19:40:09 +01:00
Przemyslaw Szczepaniak
f77b2de1a9 Fixes for API Review: android.speech.tts
Bug: 21571893
Change-Id: Icd25f4aa9a465050c7410c7bfec004a71ba24548
2015-06-12 18:32:13 +01:00
Cedric Ho
8fedcdad36 Add getCallingUid() to RecognitionService.Callback.
Change-Id: I596471625eee24ec93d08650c33461d35ad0aa07
2015-05-27 09:51:19 -07:00
Niels Egberts
837fba984e Don't strip country and variant from locale.
When the synthesizer returns LANG_AVAILABLE or LANG_COUNTRY_AVAILABLE
for a certain locale, we strip the country and variant from the locale
before asking the synthesizer for the default voice name for this
locale.

This can prevent the synthesizer from picking the right locale. For
instance it prevents the synthesizer from picking en-gb if en-au is
requested, now it can only have a single preferred voice for all English
countries.

The solution is not to strip the country and variant from the locale.
This is not likely to break anything, because the input to
onGetDefaultVoiceNameFor was never expected to be a subset of all
supported language-country-variant combinations. The default
implementation handles this correctly.

Change-Id: I017f69d321039c7aa7a3ef5a09ba138e35b66670
(cherry picked from commit 4758e99783)
2015-05-07 15:02:46 +00:00
Cedric Ho
ccc6e57848 Add android.speech.RecognizerIntent EXTRA_PREFER_OFFLINE to indicate
whether to only use an offline speech recognition engine.

Change-Id: I15fe9b31f74af1438a018a76a9c7755b43bdc835
2015-04-27 16:17:24 -07:00
Niels Egberts
f3d78656df Fix parens typos in documentation.
Change-Id: I4853ed72904985b1dab11f26cd6c5a332b884fc8
2015-04-10 18:08:28 +01:00
Tor Norbye
417ee5ba89 Add resource type annotations to some APIs
Change-Id: I37c8afdaea455aa92bc8270bb2dfd60616c5f9bc
2015-03-13 11:20:45 -07:00
John Spurlock
08c7116ab9 Remove unused imports in frameworks/base.
Change-Id: I031443de83f93eb57a98863001826671b18f3b17
2015-02-28 14:47:49 -05:00
Tor Norbye
7b9c912f53 Add @ResourceInt annotations on APIs
Change-Id: I119cc059c2f8bd98fd585fc84ac2b1b7d5892a08
2015-02-18 07:49:03 -08:00
Przemyslaw Szczepaniak
4b73867a12 Add UtteranceProgressListener#onStop callback
New UtteranceProgressListener callback that allows
to detect a call to TextToSpeech#stop() (or QUEUE_FLUSH usage)
from the same client, or a QUEUE_DESTROY usage from any other
client (Talkback uses it to preempt other users of TextToSpeech
queue). This change is required for seamless Books read aloud
feature+Talkback usage.

+ Fixes for broken tests/TtsTests

Bug: 17901521

Change-Id: I30d2f297bb7c8d05cbeb16f63e85c1be0cca5c84
2014-12-09 11:06:06 +00:00
Jeff Brown
9615697902 Fix race in RecognizerService teardown.
Use a WeakReference to refer to the outer class to prevent leaks.
Ensure atomicity of access to the reference.

Bug: 17584947
Change-Id: I7ad7c7793b60fa125e04fc4d803ed905e8a00a95
2014-10-02 12:10:08 -07:00
Jerome Poichet
c1fb6dc1a4 Make sure cancel is called on tear down.
- Make sure cancel is called when consumer of SpeechRecognizer calls
  destroy.
- If consumer goes away, make sure to call cancel as well.

b/17584947 Pressing mic button in Music hoses audio

Change-Id: Ibe1198b37fe6167493a8694f9089d970f1eb07de
2014-09-30 17:56:27 -07:00
Przemyslaw Szczepaniak
6ddd9c29b3 Fix ambiguous TTS#playSilence method.
Due to recent fixes for TTS API review (b/17389935)
overloaded playSilence method became ambiguous when
the last argument is null. This change renames the new
method to playSilentUtterance solving the issue.

Also, since LMP API level is 21, I updated invalid
references to it as API level 20 inside speech.tts.

Bug: 17389935
Change-Id: I9f9fae988240d1cec45d44650e53ffc29803ccac
2014-09-25 11:26:31 +01:00
Przemyslaw Szczepaniak
f9ba548f21 Fix issues with new TTS API
Bug: 17389935
Change-Id: I59234b3222f59dc89be7e40f7d4706b1f8c610ce
2014-09-22 17:39:16 +01:00
Przemyslaw Szczepaniak
3786bc5498 Replace TreeSet with HashSet.
Both Locale and Voice do not implement Comparable.

Bug: 17467923
Change-Id: I683577e5b18ae1892e1ccea5ea241e1d016c9517
2014-09-11 16:56:46 +01:00
Przemyslaw Szczepaniak
35c7698a1b API review requests for the TTS package.
- New TextToSpeechService methods are no longer protected.
- s/getRequiresNetworkConnection/isNetworkConnectionRequired
- New TextToSpeec#play.. methods use a Bundle instead of a HashMap
- New synthesizeToFile(), addSpeech(), addEarcon() methods
take a File instead of a String with filepath.
- TextToSpeechService#s/isValidVoiceName/onIsValidVoiceName

Bug:17389935,17253934
Change-Id: Iec76f59015c34104683c050fe1ff1ceccd604134
2014-09-08 11:04:19 +01:00
Przemyslaw Szczepaniak
fd80746bb9 Set the TTS voice name for the default language.
This changes makes the initial, default language set and
the #setLanguage call with the default language as input
exactly the same.

Previously, the requests made after the initial default language
set were missing the name of the default voice.

+ Some tests clean-up. Some of them fail due to issues with
Locale#toLanguageTag upper-casing the variant field.

Change-Id: I5470617007fe45462b7198bf62a03eb5fe47a590
2014-08-05 14:50:34 +01:00
Jean-Michel Trivi
289cc8e887 API for audio session ID generation
Expose the value used by the framework to generate an audio
 session ID when a value isn't known.
Rename allocateAudioSessionId() to generateAudioSessionId()
 as this operation doesn't "allocate" anything, and there is
 no allocated resource to free after this operation.

Bug 16401631

Change-Id: I7a7bc05b39ea0b024ff225254eb755a9c85a2ad9
2014-07-20 11:25:48 -07:00
Przemyslaw Szczepaniak
672695e423 Add AudioAttributes support in the TTS.
Bug: 16259299
Change-Id: I53f4f7a2b9a3b9a422affaf6abe4aca258e67d7f
2014-07-17 13:19:39 +01:00
Przemyslaw Szczepaniak
cafd15216e Fix TTS regression, TTS#stop can result in #onDone callback.
Regressinon in the L, side effect of the rewrite. In pre-L android,
UtteranceProgressListener#onDone was called (but only if client
received UtteranceProgressListener#onStart for the utterance in progress)
after client called TextToSpeech#stop. This changeset reinstates
this behaviour.
+ Removed not used fallback callback

Bug: 16149006
Change-Id: I2eb5ede0abe6f5717b07f09adad861465575c238
2014-07-10 14:32:31 +00:00
Niels Egberts
34d4ac88f7 Remove Markup and Utterance classes.
Markup is replaced by TtsSpan, and the Utterance class will be replaced
by TtsSpanBuilder.

Change-Id: I443786681f065ad8458fc05825de3ef182db8062
2014-07-08 14:53:35 +01:00
Przemyslaw Szczepaniak
ad6df74ada Add support for voices in TTS API.
Voices allow to expose multiple backends/voice packs for a single
Locale. This is an attempt to port this feature from V2 API.

Bug: 15834470
Change-Id: I0117de238cfcf028bcec5344b8d65c960b96b98c
2014-07-04 11:28:06 +01:00
Niels Egberts
f8fd342091 First argument of playSilence is incorrect in javaDoc.
Change-Id: Icc059471e61fb6154108b74ea45cb06554d80631
2014-07-02 16:21:20 +00:00
Niels Egberts
795d777ee1 Forgot to deprecate a method in current.txt before merging earlier change.
Also includes a comment fix and line size changes in TextToSpeech.java.

Change-Id: Ia5842b694bca6cd9cae035164ffc605451e72d8b
2014-07-02 16:09:54 +00:00
Niels Egberts
df7deefe8e Support for CharSequences in the V1 API.
Two newly deprecated methods:
  - TextToSpeech.speak (over TextToSpeech.speak with mandatory utteranceId)
  - SynthesisRequest.getText (over SynthesisRequest.getCharSequenceText)

Change-Id: I8a75ed335c91074c72d6ef374ff8b9c79a7c208d
2014-07-02 15:23:33 +00:00
Przemyslaw Szczepaniak
5cbf17ca05 Add support for audio session id in the TTS
+ #playEarcon & #queueAudio respects request Volume/Pan settings.

Bug:15432115
Change-Id: I136afef77afbc56c34810c64123f7be4b431d378
2014-07-02 11:28:24 +01:00
Przemyslaw Szczepaniak
fc4b289037 Remove TextToSpeechClient API.
Removed all of TTS V2 api with exception of error codes.

Bug: 15834470
Change-Id: I9d9d2aad01811af9b86bf7a3fd018a8d4e5c2f33
2014-06-30 11:25:12 +01:00
Przemyslaw Szczepaniak
6dfa6e2a9b Fix typo and broken sdk build.
Change-Id: Icd1641955d1ca88396219db05312a4a9fd77ea80
2014-06-13 13:43:26 +01:00
Przemyslaw Szczepaniak
e31ab2d8fc Merge "Expose "default tts locale" to the TTS V2 API." 2014-06-11 15:57:38 +00:00
Przemyslaw Szczepaniak
1b5637ee32 Expose "default tts locale" to the TTS V2 API.
This change allows TTS V2 API client applications to honor the
"default TTS locale" set by the user in the TTS settings.

Note that the TTS V1 API uses 3 character country/language codes
for locale encoding. It's the only system component that does
that. TTS V2 uses the standard, valid Locale objects. The default
TTS locale setting was stored as a 3 character locale string with
"-" as the separator.

This change switches the TTS locale setting format to the output of
Locale.toString() call (on a valid Locale object). Methods used for
reading this value can interpret both forms and try to return a valid
Locale object as an output.

Change-Id: Ice2e6c25a43eb9dd6e17d371ee582c2dae3329c9
2014-06-11 13:49:48 +01:00
Przemyslaw Szczepaniak
d3919a318a Add missing copyright headers in speech.tts
Change-Id: Icf1c3cf71ac45cb00606c8034af375e657c31ea5
2014-06-12 12:39:46 +00:00
Przemyslaw Szczepaniak
e3abed72d6 Add missing #isSpeaking to TTS API V2
TextToSpeech#isSpeaking queries TTS engine if it's
currently outputting any audio, it was present in the
TTS API V1.

Change-Id: Iee4a91976b9b80653811fb458ac48d75418752cf
2014-06-04 09:16:55 +00:00
Niels Egberts
a6cc9b85ad Markup support for framework
Change-Id: Ia5ad6cff7593c295944a90775a1b061c95f5cc3f
2014-05-30 13:48:09 +00:00
Przemyslaw Szczepaniak
067a21b246 TTS Connection callbacks are called on main thread.
After experimenting with the new TTS API I found out that receiving
ConnectionCallbacks#onEngineStatusChange and #onServiceDisconnected
callbacks on non-main thread are problematic. They are very rare and
overhead of dealing with them in separate thread is high - in most
cases user just wants to process those callbacks in the main thread
context. This change should make new API usage easier.

+ Fixed default values of speech speed in voices from v1->v2 wrapper.

Change-Id: I76d3b607b3b931b7eb10aa180775fd3607c43bd9
2014-05-16 16:47:46 +01:00
Przemyslaw Szczepaniak
de1b5ae7a7 Add (hidden) TTSEngines#isLocaleSetToDefaultForEngine method.
TTSEngines#isLocaleSetToDefaultForEngine allows the Settings application
to distinguish if the TTS engine locale is blank (set to follow the device
locale) or if it's set to the same value as the device locale.

Change-Id: I462584547d69c21cde4ac317c8a3b3bbc1680cae
2014-05-12 16:07:31 +01:00
Glenn Kasten
34a37bdebb Add AudioFormat.getBytesPerSample and use it
Change-Id: I90a40987ea99006af4a6e31136078c04976eb54d
2014-05-06 09:11:52 -07:00
Przemyslaw Szczepaniak
5decae39b6 Remove "final" from TextToSpeechClient class.
It hinders attempts to mock the TextToSpeechClient
class in tests.

+ javadoc typo fix

Change-Id: I5b4590824d7e89b58451bdde457a627786333373
2014-04-10 16:17:09 +00:00
Przemyslaw Szczepaniak
a1788af344 Documentation update for TextToSpeech#getFeatures
Added note that it may return null in case of error.

Bug: 12323454
Change-Id: I246f7e894c5e8a6421bdd72c7623c72e8a13fc3a
2014-03-24 15:07:03 +00:00
Przemyslaw Szczepaniak
952c0fd7bc Do not reset language in case of the TTS service reconnect.
Bug:12428804
Change-Id: I0b1b1274c47edd28eae1701808d50aeb6c36324c
2014-03-21 11:21:07 +00:00
Mark Renouf
b37866db46 Make InternalListener static to avoid referencing SpeechRecognizer.
Change-Id: I03bc1a5f5188551608395f3468aa69e622601820
2014-03-17 18:15:51 -04:00
Przemyslaw Szczepaniak
8399aae0a0 Add public SynthesisRequestV2 constructor.
While implementing the new TTS API, I found out that it's very difficult
to create an SynthesisRequestV2 instance for testing purposes - it's
a final class, with no publicly visible constructors.

Bug: 8259486
Change-Id: I88b84fd8ad1ac6960f3932863ca758657f9547ff
2014-01-30 13:27:00 +00:00