Commit Graph

294 Commits

Author SHA1 Message Date
Eugene Susla
726b51a26e Copy PermissionChecker from support lib and use in RcognitionService
Fixes: 73511076, 73311729
Test: presubmit
Change-Id: Ie98f67ffee4744050ac85d8b229370a16a76a194
2018-02-23 12:53:55 -08:00
Niels Egberts
32011ea4f1 Fix race condition with calling stop() before run()
The code assumed that when stop() is called before run(), it's not
neccessary to signal mNotFull, but in rare cases the synthesizer may
already have filled the buffer before run() is called.

Test: manual

Bug: 70887227
Change-Id: I83117f3541d37830b344bc9eda34e1f380b58e76
2018-02-13 18:13:36 +00:00
Jeff Sharkey
ce8db99114 Add more IntDef prefixes for auto-documenting.
Test: builds, boots
Bug: 70177949
Exempt-From-Owner-Approval: annotation-only changes
Change-Id: I76dde6054e06f52240bd4b1a0f196dcb74623608
2017-12-13 20:05:36 -07:00
Kazuhiro Inaba
35e6bb474d TTS: Fix a race condition between enqueueSpeechItem and stopForApp.
When speak() is immediately followed by a stop(), the speak may not be
stopped at all due to a race condition.

Bug: 63649835
Test: android.speech.tts.cts.TextToSpeechServiceTest#testSpeakStop
Change-Id: Iae5660b455f5d845aa119c902057e2ca7131ce1b
2017-08-03 04:20:21 +00:00
Kazuhiro Inaba
a81d17b795 TTS: Ensure to callback onStop() from SynthesisPlaybackQueueItem.
The previous implementation calls back the dispatcher only at the end
of run() loop. It means, if stop() is called after enqueueing and
before running, none of onSuccess, onStop, or onError is called for
the items in the queue.

Bug: 63649835
Test: android.speech.tts.cts.TextToSpeechServiceTest#testSpeakStop
Change-Id: Ib20cb0e9157859866f694439858a27369ba8026e
2017-07-25 17:12:25 +09:00
Jeff Sharkey
000ce80505 Updates based on API council guidance.
Test: builds, boots
Change-Id: I223faf55c1e1b4d81d11b4c8b2d93ccd131c969b
Fixes: 37775662
Fixes: 37748635
Fixes: 37673408
Fixes: 37672564
Fixes: 37672218
Fixes: 37638323
Fixes: 37637423
2017-04-29 13:14:17 -06:00
Niels Egberts
04637f3d4d Document examples where a developer might use the APIs.
Test: mmma frameworks/base/
Bug: 35767714

Change-Id: I845db36869b84a18e79d7fe28f10031cfe836617
2017-04-13 13:52:07 +01:00
Amith Yamasani
53e100c468 Provide deprecated API to avoid build breakage
Restored onUtteranceRangeStart() temporarily as a deprecated API.

Bug: 36646809
Test: N/A
Change-Id: I7da927aca4f4ad1f5cc76564e8fdc4261849898b
2017-03-27 14:36:37 -07:00
Niels Egberts
5d0ea0fe21 Add time markers to synthesizeToFile API.
Also rename onUtteranceRangeStart to onRangeStart based on feedback from
the API council.

Bug: 35767714
Bug: 35767290
Test: cts-tradefed run cts-dev --module CtsSpeechTestCases
Change-Id: I2c17a06e401313d4f35e5ec4958c2251c195ef05
2017-03-22 13:28:59 +00:00
Sergio Sancho
07d98a9d68 Ensure we set the notification marker position by calling updateMarker()
just after the AudioTrack is initialized.
This solve the issue with cached synthesis in which updateMarker was
called before AudioTracker initialization and we never got the
callbacks.

Test: Built android and flashed to a device.
Change-Id: I9053d1d046cc9a76aeedd307d5d48920e26e584d
2017-02-14 12:35:13 +00:00
Sergio Sancho
7c810edbce Merge "Ensure default pitch is used when none is specified." 2017-02-08 19:28:55 +00:00
Sergio Sancho
b0cde2caba Ensure default pitch is used when none is specified.
Test: Manual
Change-Id: I09ab4ccea439d01c65a06c3c44b4ff210ddf7f54
2017-01-26 20:39:05 +00:00
Niels Egberts
65c5078456 Implement time markers for TTS.
The service can inform the framework at which frame a part of the input
is spoken, and that information is then relayed to the client.

This can be used to highlight the currently spoken word/sentence or to
resume synthesis requests at the start of the last word/sentence.

Test: manual
Change-Id: Ie20a6764a8788cc3539cb058425e55eb6fde07db
2017-01-24 15:27:16 +00:00
Niels Egberts
9b01193770 Merge "Remove refernces to V1 API, as V2 doesn't exist anymore." 2017-01-03 11:52:42 +00:00
Niels Egberts
01dedf59db Remove refernces to V1 API, as V2 doesn't exist anymore.
Also ran formatter on modified lines.

Test: Refactor only, CTS tests still passing.
Change-Id: I1309cfa8e9e731d3450c13d96038e6b5d53a12e1
2016-12-23 15:39:05 +00:00
Niels Egberts
2c80a03823 Remove redundant public modifiers in interfaces.
Also applied formatter on modified lines.

Test: refactoring CL. Existing unit tests still pass.
Change-Id: I9a7c33e7590260ede0811dd1b50b565b0f8d2f87
2016-12-23 12:23:54 +00:00
Niels Egberts
10db95b316 Fix issue when QUEUE_DESTROY arrive at the same time.
When multiple QUEUE_DESTROY messages arrive in a short timespan, some
messages were not flushed. This is because every QUEUE_DESTROY message
resets mFlushAll just before it starts playing itself. The solution
is to keep a counter of the amount of flushes that are still behind it on
the queue and keep flushing until the last one is reached.

Bug: 27555444
Change-Id: Ic24aa2250bf684e74b541907e4c57e0d5f0069ca
2016-04-08 11:18:23 +01:00
Glenn Kasten
33b840444f Use audio_session_t consistently
Also prefer AudioManager.AUDIO_SESSION_ID_GENERATE over
AudioSystem.AUDIO_SESSION_ALLOCATE, because
AudioSystem.AUDIO_SESSION_ALLOCATE is @hide.

Bug: 27562099
Change-Id: I5924554feb919db7f2390f5b062faedd515421af
2016-03-10 10:35:49 -08:00
Niels Egberts
c99ba1c3ed API to listen in on the synthesized audio.
Change-Id: Ic943d39a0540f0061ef6f629e4934dc71f69ab6b
2016-01-25 15:20:59 +00:00
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