1f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert/* 2f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * Copyright (C) 2009 Google Inc. 3f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * 4f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); 5f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * you may not use this file except in compliance with the License. 6f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * You may obtain a copy of the License at 7f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * 8f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 9f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * 10f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * Unless required by applicable law or agreed to in writing, software 11f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS, 12f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * See the License for the specific language governing permissions and 14f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * limitations under the License. 15f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert */ 16f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert#ifndef ANDROID_TTS_H 177ffd31ba2584359996e04cd3d4d92f810d651066Narayan Kamath#define ANDROID_TTS_H 18f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 19f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// This header defines the interface used by the Android platform 20f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// to access Text-To-Speech functionality in shared libraries that implement 21f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// speech synthesis and the management of resources associated with the 22f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// synthesis. 23f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 24f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// The shared library must contain a function named "android_getTtsEngine" 25f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// that returns an 'android_tts_engine_t' instance. 26f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 27f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert#ifdef __cplusplus 28f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringertextern "C" { 29f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert#endif 30f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 31f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert#define ANDROID_TTS_ENGINE_PROPERTY_CONFIG "engineConfig" 32f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert#define ANDROID_TTS_ENGINE_PROPERTY_PITCH "pitch" 33f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert#define ANDROID_TTS_ENGINE_PROPERTY_RATE "rate" 34f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert#define ANDROID_TTS_ENGINE_PROPERTY_VOLUME "volume" 35f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 36f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringerttypedef enum { 37f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_SUCCESS = 0, 38f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_FAILURE = -1, 39f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_FEATURE_UNSUPPORTED = -2, 40f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_VALUE_INVALID = -3, 41f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_PROPERTY_UNSUPPORTED = -4, 42f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_PROPERTY_SIZE_TOO_SMALL = -5, 43f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_MISSING_RESOURCES = -6 44f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert} android_tts_result_t; 45f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 46f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringerttypedef enum { 47f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_LANG_COUNTRY_VAR_AVAILABLE = 2, 48f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_LANG_COUNTRY_AVAILABLE = 1, 49f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_LANG_AVAILABLE = 0, 50f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_LANG_MISSING_DATA = -1, 51f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_LANG_NOT_SUPPORTED = -2 52f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert} android_tts_support_result_t; 53f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 54f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringerttypedef enum { 55f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_SYNTH_DONE = 0, 56f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_SYNTH_PENDING = 1 57f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert} android_tts_synth_status_t; 58f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 59f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringerttypedef enum { 60f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_CALLBACK_HALT = 0, 61f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_CALLBACK_CONTINUE = 1 62f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert} android_tts_callback_status_t; 63f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 64f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// Supported audio formats 657ffd31ba2584359996e04cd3d4d92f810d651066Narayan Kamath// 667ffd31ba2584359996e04cd3d4d92f810d651066Narayan Kamath// NOTE: This is duplicated in compat/include/TtsEngine.h 677ffd31ba2584359996e04cd3d4d92f810d651066Narayan Kamath// Please make changes there as well. 68f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringerttypedef enum { 69f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_AUDIO_FORMAT_INVALID = -1, 70f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_AUDIO_FORMAT_DEFAULT = 0, 71f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_AUDIO_FORMAT_PCM_16_BIT = 1, 72f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert ANDROID_TTS_AUDIO_FORMAT_PCM_8_BIT = 2, 73f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert} android_tts_audio_format_t; 74f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 75f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 76f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert/* An android_tts_engine_t object can be anything, but must have, 77f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * as its first field, a pointer to a table of functions. 78f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * 79f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * See the full definition of struct android_tts_engine_t_funcs_t 80f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * below for details. 81f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert */ 82f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringerttypedef struct android_tts_engine_funcs_t android_tts_engine_funcs_t; 83f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 84f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringerttypedef struct { 85f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_engine_funcs_t *funcs; 86f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert} android_tts_engine_t; 87f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 88f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert/* This function must be located in the TTS Engine shared library 89f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * and must return the address of an android_tts_engine_t library. 90f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert */ 91f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringertextern android_tts_engine_t *android_getTtsEngine(); 92f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 93f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert/* Including the old version for legacy support (Froyo compatibility). 94f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert * This should return the same thing as android_getTtsEngine. 95f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert */ 96f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringertextern "C" android_tts_engine_t *getTtsEngine(); 97f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 98f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// A callback type used to notify the framework of new synthetized 99f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// audio samples, status will be SYNTH_DONE for the last sample of 100f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// the last request, of SYNTH_PENDING otherwise. 101f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// 102f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// This is passed by the framework to the engine through the 103f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// 'engine_init' function (see below). 104f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// 105f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// The callback for synthesis completed takes: 106f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// @param [inout] void *& - The userdata pointer set in the original 107f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// synth call 108f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// @param [in] uint32_t - Track sampling rate in Hz 109f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// @param [in] uint32_t - The audio format 110f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// @param [in] int - The number of channels 111f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// @param [inout] int8_t *& - A buffer of audio data only valid during the 112f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// execution of the callback 113f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// @param [inout] size_t & - The size of the buffer 114f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// @param [in] tts_synth_status - indicate whether the synthesis is done, or 115f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// if more data is to be synthesized. 116f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// @return TTS_CALLBACK_HALT to indicate the synthesis must stop, 117f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// TTS_CALLBACK_CONTINUE to indicate the synthesis must continue if 118f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// there is more data to produce. 119f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringerttypedef android_tts_callback_status_t (*android_tts_synth_cb_t) 120f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void **pUserData, 121f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert uint32_t trackSamplingHz, 122f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_audio_format_t audioFormat, 123f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert int channelCount, 124f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert int8_t **pAudioBuffer, 125f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert size_t *pBufferSize, 126f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_synth_status_t status); 127f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 128f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 129f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// The table of function pointers that the android_tts_engine_t must point to. 130f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// Note that each of these functions will take a handle to the engine itself 131f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// as their first parameter. 132f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert// 133f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 134f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringertstruct android_tts_engine_funcs_t { 135f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // reserved fields, ignored by the framework 136f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // they must be placed here to ensure binary compatibility 137f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // of legacy binary plugins. 138f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert void *reserved[2]; 139f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 140f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Initialize the TTS engine and returns whether initialization succeeded. 141f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param synthDoneCBPtr synthesis callback function pointer 142f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_SUCCESS, or TTS_FAILURE 143f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_result_t (*init) 144f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine, 145f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_synth_cb_t synthDonePtr, 146f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *engineConfig); 147f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 148f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Shut down the TTS engine and releases all associated resources. 149f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_SUCCESS, or TTS_FAILURE 150f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_result_t (*shutdown) 151f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine); 152f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 153f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Interrupt synthesis and flushes any synthesized data that hasn't been 154f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // output yet. This will block until callbacks underway are completed. 155f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_SUCCESS, or TTS_FAILURE 156f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_result_t (*stop) 157f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine); 158f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 159f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Returns the level of support for the language, country and variant. 160f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_LANG_COUNTRY_VAR_AVAILABLE if the language, country and variant are supported, 161f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // and the corresponding resources are correctly installed 162f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // TTS_LANG_COUNTRY_AVAILABLE if the language and country are supported and the 163f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // corresponding resources are correctly installed, but there is no match for 164f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // the specified variant 165f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // TTS_LANG_AVAILABLE if the language is supported and the 166f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // corresponding resources are correctly installed, but there is no match for 167f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // the specified country and variant 168f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // TTS_LANG_MISSING_DATA if the required resources to provide any level of support 169f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // for the language are not correctly installed 170f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // TTS_LANG_NOT_SUPPORTED if the language is not supported by the TTS engine. 171f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_support_result_t (*isLanguageAvailable) 172f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine, 173f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *lang, 174f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *country, 175f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *variant); 176f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 177f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Load the resources associated with the specified language. The loaded 178f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // language will only be used once a call to setLanguage() with the same 179f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // language value is issued. Language and country values are coded according to the ISO three 180f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // letter codes for languages and countries, as can be retrieved from a java.util.Locale 181f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // instance. The variant value is encoded as the variant string retrieved from a 182f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // java.util.Locale instance built with that variant data. 183f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param lang pointer to the ISO three letter code for the language 184f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param country pointer to the ISO three letter code for the country 185f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param variant pointer to the variant code 186f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_SUCCESS, or TTS_FAILURE 187f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_result_t (*loadLanguage) 188f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine, 189f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *lang, 190f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *country, 191f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *variant); 192f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 193f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Load the resources associated with the specified language, country and Locale variant. 194f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // The loaded language will only be used once a call to setLanguageFromLocale() with the same 195f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // language value is issued. Language and country values are coded according to the ISO three 196f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // letter codes for languages and countries, as can be retrieved from a java.util.Locale 197f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // instance. The variant value is encoded as the variant string retrieved from a 198f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // java.util.Locale instance built with that variant data. 199f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param lang pointer to the ISO three letter code for the language 200f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param country pointer to the ISO three letter code for the country 201f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param variant pointer to the variant code 202f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_SUCCESS, or TTS_FAILURE 203f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_result_t (*setLanguage) 204f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine, 205f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *lang, 206f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *country, 207f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *variant); 208f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 209f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Retrieve the currently set language, country and variant, or empty strings if none of 210f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // parameters have been set. Language and country are represented by their 3-letter ISO code 211f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param[out] pointer to the retrieved 3-letter code language value 212f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param[out] pointer to the retrieved 3-letter code country value 213f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param[out] pointer to the retrieved variant value 214f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_SUCCESS, or TTS_FAILURE 215f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_result_t (*getLanguage) 216f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine, 217f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert char *language, 218f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert char *country, 219f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert char *variant); 220f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 221f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Notifies the engine what audio parameters should be used for the synthesis. 222f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // This is meant to be used as a hint, the engine implementation will set the output values 223f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // to those of the synthesis format, based on a given hint. 224f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param[inout] encoding in: the desired audio sample format 225f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // out: the format used by the TTS engine 226f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param[inout] rate in: the desired audio sample rate 227f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // out: the sample rate used by the TTS engine 228f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param[inout] channels in: the desired number of audio channels 229f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // out: the number of channels used by the TTS engine 230f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_SUCCESS, or TTS_FAILURE 231f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_result_t (*setAudioFormat) 232f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine, 233f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_audio_format_t* pEncoding, 234f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert uint32_t* pRate, 235f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert int* pChannels); 236f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 237f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Set a property for the the TTS engine 238f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // "size" is the maximum size of "value" for properties "property" 239f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param property pointer to the property name 240f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param value pointer to the property value 241f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param size maximum size required to store this type of property 242f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_PROPERTY_UNSUPPORTED, or TTS_SUCCESS, or TTS_FAILURE, 243f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // or TTS_VALUE_INVALID 244f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_result_t (*setProperty) 245f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine, 246f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *property, 247f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *value, 248f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const size_t size); 249f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 250f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Retrieve a property from the TTS engine 251f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param property pointer to the property name 252f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param[out] value pointer to the retrieved language value 253f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param[inout] iosize in: stores the size available to store the 254f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // property value. 255f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // out: stores the size required to hold the language 256f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // value if getLanguage() returned 257f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // TTS_PROPERTY_SIZE_TOO_SMALL, unchanged otherwise 258f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_PROPERTY_UNSUPPORTED, or TTS_SUCCESS, 259f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // or TTS_PROPERTY_SIZE_TOO_SMALL 260f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_result_t (*getProperty) 261f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine, 262f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *property, 263f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert char *value, 264f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert size_t *iosize); 265f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 266f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Synthesize the text. 267f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // As the synthesis is performed, the engine invokes the callback to notify 268f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // the TTS framework that it has filled the given buffer, and indicates how 269f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // many bytes it wrote. The callback is called repeatedly until the engine 270f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // has generated all the audio data corresponding to the text. 271f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Note about the format of the input: the text parameter may use the 272f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // following elements 273f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // and their respective attributes as defined in the SSML 1.0 specification: 274f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // * lang 275f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // * say-as: 276f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o interpret-as 277f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // * phoneme 278f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // * voice: 279f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o gender, 280f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o age, 281f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o variant, 282f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o name 283f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // * emphasis 284f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // * break: 285f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o strength, 286f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o time 287f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // * prosody: 288f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o pitch, 289f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o contour, 290f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o range, 291f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o rate, 292f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o duration, 293f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // o volume 294f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // * mark 295f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Differences between this text format and SSML are: 296f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // * full SSML documents are not supported 297f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // * namespaces are not supported 298f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // Text is coded in UTF-8. 299f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param text the UTF-8 text to synthesize 300f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param userdata pointer to be returned when the call is invoked 301f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param buffer the location where the synthesized data must be written 302f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @param bufferSize the number of bytes that can be written in buffer 303f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert // @return TTS_SUCCESS or TTS_FAILURE 304f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert android_tts_result_t (*synthesizeText) 305f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert (void *engine, 306f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert const char *text, 307f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert int8_t *buffer, 308f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert size_t bufferSize, 309f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert void *userdata); 310f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert}; 311f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 312f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert#ifdef __cplusplus 313f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert} 314f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert#endif 315f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert 316f41e1f808fbcf9014c0a5668fba4eff6dd051366Bjorn Bringert#endif /* ANDROID_TTS_H */ 317