111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* 211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Copyright (C) 2009 Google Inc. 311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * 411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Licensed under the Apache License, Version 2.0 (the "License"); 511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * you may not use this file except in compliance with the License. 611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * You may obtain a copy of the License at 711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * 811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * http://www.apache.org/licenses/LICENSE-2.0 911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * 1011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Unless required by applicable law or agreed to in writing, software 1111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * distributed under the License is distributed on an "AS IS" BASIS, 1211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * See the License for the specific language governing permissions and 1411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * limitations under the License. 1511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */ 1611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifndef ANDROID_TTS_H 1711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define ANDROID_TTS_H 1811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 1911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// This header defines the interface used by the Android platform 2011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// to access Text-To-Speech functionality in shared libraries that implement 2111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// speech synthesis and the management of resources associated with the 2211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// synthesis. 2311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 2411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// The shared library must contain a function named "android_getTtsEngine" 2511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// that returns an 'android_tts_engine_t' instance. 2611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 2711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifdef __cplusplus 2811cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern "C" { 2911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif 3011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 3111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <stdint.h> 3211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 3311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define ANDROID_TTS_ENGINE_PROPERTY_CONFIG "engineConfig" 3411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define ANDROID_TTS_ENGINE_PROPERTY_PITCH "pitch" 3511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define ANDROID_TTS_ENGINE_PROPERTY_RATE "rate" 3611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define ANDROID_TTS_ENGINE_PROPERTY_VOLUME "volume" 3711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 3811cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttypedef enum { 3911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_SUCCESS = 0, 4011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_FAILURE = -1, 4111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_FEATURE_UNSUPPORTED = -2, 4211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_VALUE_INVALID = -3, 4311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_PROPERTY_UNSUPPORTED = -4, 4411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_PROPERTY_SIZE_TOO_SMALL = -5, 4511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_MISSING_RESOURCES = -6 4611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} android_tts_result_t; 4711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 4811cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttypedef enum { 4911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_LANG_COUNTRY_VAR_AVAILABLE = 2, 5011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_LANG_COUNTRY_AVAILABLE = 1, 5111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_LANG_AVAILABLE = 0, 5211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_LANG_MISSING_DATA = -1, 5311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_LANG_NOT_SUPPORTED = -2 5411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} android_tts_support_result_t; 5511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 5611cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttypedef enum { 5711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_SYNTH_DONE = 0, 5811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_SYNTH_PENDING = 1 5911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} android_tts_synth_status_t; 6011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 6111cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttypedef enum { 6211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_CALLBACK_HALT = 0, 6311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_CALLBACK_CONTINUE = 1 6411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} android_tts_callback_status_t; 6511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 6611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// Supported audio formats 6711cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttypedef enum { 6811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_AUDIO_FORMAT_INVALID = -1, 6911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_AUDIO_FORMAT_DEFAULT = 0, 7011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_AUDIO_FORMAT_PCM_16_BIT = 1, 7111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ANDROID_TTS_AUDIO_FORMAT_PCM_8_BIT = 2, 7211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} android_tts_audio_format_t; 7311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 7411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 7511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* An android_tts_engine_t object can be anything, but must have, 7611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * as its first field, a pointer to a table of functions. 7711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * 7811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * See the full definition of struct android_tts_engine_t_funcs_t 7911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * below for details. 8011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */ 8111cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttypedef struct android_tts_engine_funcs_t android_tts_engine_funcs_t; 8211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 8311cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttypedef struct { 8411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_engine_funcs_t *funcs; 8511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} android_tts_engine_t; 8611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 8711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* This function must be located in the TTS Engine shared library 8811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and must return the address of an android_tts_engine_t library. 8911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */ 9011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern android_tts_engine_t *android_getTtsEngine(); 9111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 9211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Including the old version for legacy support (Froyo compatibility). 9311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * This should return the same thing as android_getTtsEngine. 9411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */ 9511cd02dfb91661c65134cac258cf5924270e9d2Dan Albertandroid_tts_engine_t *getTtsEngine(); 9611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 9711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// A callback type used to notify the framework of new synthetized 9811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// audio samples, status will be SYNTH_DONE for the last sample of 9911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// the last request, of SYNTH_PENDING otherwise. 10011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// 10111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// This is passed by the framework to the engine through the 10211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// 'engine_init' function (see below). 10311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// 10411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// The callback for synthesis completed takes: 10511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// @param [inout] void *& - The userdata pointer set in the original 10611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// synth call 10711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// @param [in] uint32_t - Track sampling rate in Hz 10811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// @param [in] uint32_t - The audio format 10911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// @param [in] int - The number of channels 11011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// @param [inout] int8_t *& - A buffer of audio data only valid during the 11111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// execution of the callback 11211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// @param [inout] size_t & - The size of the buffer 11311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// @param [in] tts_synth_status - indicate whether the synthesis is done, or 11411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// if more data is to be synthesized. 11511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// @return TTS_CALLBACK_HALT to indicate the synthesis must stop, 11611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// TTS_CALLBACK_CONTINUE to indicate the synthesis must continue if 11711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// there is more data to produce. 11811cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttypedef android_tts_callback_status_t (*android_tts_synth_cb_t) 11911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void **pUserData, 12011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert uint32_t trackSamplingHz, 12111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_audio_format_t audioFormat, 12211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert int channelCount, 12311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert int8_t **pAudioBuffer, 12411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert size_t *pBufferSize, 12511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_synth_status_t status); 12611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 12711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 12811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// The table of function pointers that the android_tts_engine_t must point to. 12911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// Note that each of these functions will take a handle to the engine itself 13011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// as their first parameter. 13111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert// 13211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 13311cd02dfb91661c65134cac258cf5924270e9d2Dan Albertstruct android_tts_engine_funcs_t { 13411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // reserved fields, ignored by the framework 13511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // they must be placed here to ensure binary compatibility 13611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // of legacy binary plugins. 13711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert void *reserved[2]; 13811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 13911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Initialize the TTS engine and returns whether initialization succeeded. 14011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param synthDoneCBPtr synthesis callback function pointer 14111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_SUCCESS, or TTS_FAILURE 14211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_result_t (*init) 14311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine, 14411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_synth_cb_t synthDonePtr, 14511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *engineConfig); 14611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 14711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Shut down the TTS engine and releases all associated resources. 14811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_SUCCESS, or TTS_FAILURE 14911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_result_t (*shutdown) 15011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine); 15111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 15211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Interrupt synthesis and flushes any synthesized data that hasn't been 15311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // output yet. This will block until callbacks underway are completed. 15411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_SUCCESS, or TTS_FAILURE 15511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_result_t (*stop) 15611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine); 15711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 15811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Returns the level of support for the language, country and variant. 15911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_LANG_COUNTRY_VAR_AVAILABLE if the language, country and variant are supported, 16011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // and the corresponding resources are correctly installed 16111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // TTS_LANG_COUNTRY_AVAILABLE if the language and country are supported and the 16211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // corresponding resources are correctly installed, but there is no match for 16311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // the specified variant 16411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // TTS_LANG_AVAILABLE if the language is supported and the 16511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // corresponding resources are correctly installed, but there is no match for 16611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // the specified country and variant 16711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // TTS_LANG_MISSING_DATA if the required resources to provide any level of support 16811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // for the language are not correctly installed 16911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // TTS_LANG_NOT_SUPPORTED if the language is not supported by the TTS engine. 17011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_support_result_t (*isLanguageAvailable) 17111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine, 17211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *lang, 17311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *country, 17411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *variant); 17511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 17611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Load the resources associated with the specified language. The loaded 17711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // language will only be used once a call to setLanguage() with the same 17811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // language value is issued. Language and country values are coded according to the ISO three 17911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // letter codes for languages and countries, as can be retrieved from a java.util.Locale 18011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // instance. The variant value is encoded as the variant string retrieved from a 18111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // java.util.Locale instance built with that variant data. 18211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param lang pointer to the ISO three letter code for the language 18311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param country pointer to the ISO three letter code for the country 18411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param variant pointer to the variant code 18511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_SUCCESS, or TTS_FAILURE 18611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_result_t (*loadLanguage) 18711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine, 18811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *lang, 18911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *country, 19011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *variant); 19111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 19211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Load the resources associated with the specified language, country and Locale variant. 19311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // The loaded language will only be used once a call to setLanguageFromLocale() with the same 19411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // language value is issued. Language and country values are coded according to the ISO three 19511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // letter codes for languages and countries, as can be retrieved from a java.util.Locale 19611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // instance. The variant value is encoded as the variant string retrieved from a 19711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // java.util.Locale instance built with that variant data. 19811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param lang pointer to the ISO three letter code for the language 19911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param country pointer to the ISO three letter code for the country 20011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param variant pointer to the variant code 20111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_SUCCESS, or TTS_FAILURE 20211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_result_t (*setLanguage) 20311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine, 20411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *lang, 20511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *country, 20611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *variant); 20711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 20811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Retrieve the currently set language, country and variant, or empty strings if none of 20911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // parameters have been set. Language and country are represented by their 3-letter ISO code 21011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param[out] pointer to the retrieved 3-letter code language value 21111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param[out] pointer to the retrieved 3-letter code country value 21211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param[out] pointer to the retrieved variant value 21311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_SUCCESS, or TTS_FAILURE 21411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_result_t (*getLanguage) 21511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine, 21611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert char *language, 21711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert char *country, 21811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert char *variant); 21911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 22011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Notifies the engine what audio parameters should be used for the synthesis. 22111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // This is meant to be used as a hint, the engine implementation will set the output values 22211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // to those of the synthesis format, based on a given hint. 22311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param[inout] encoding in: the desired audio sample format 22411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // out: the format used by the TTS engine 22511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param[inout] rate in: the desired audio sample rate 22611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // out: the sample rate used by the TTS engine 22711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param[inout] channels in: the desired number of audio channels 22811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // out: the number of channels used by the TTS engine 22911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_SUCCESS, or TTS_FAILURE 23011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_result_t (*setAudioFormat) 23111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine, 23211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_audio_format_t* pEncoding, 23311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert uint32_t* pRate, 23411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert int* pChannels); 23511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 23611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Set a property for the the TTS engine 23711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // "size" is the maximum size of "value" for properties "property" 23811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param property pointer to the property name 23911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param value pointer to the property value 24011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param size maximum size required to store this type of property 24111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_PROPERTY_UNSUPPORTED, or TTS_SUCCESS, or TTS_FAILURE, 24211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // or TTS_VALUE_INVALID 24311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_result_t (*setProperty) 24411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine, 24511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *property, 24611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *value, 24711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const size_t size); 24811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 24911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Retrieve a property from the TTS engine 25011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param property pointer to the property name 25111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param[out] value pointer to the retrieved language value 25211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param[inout] iosize in: stores the size available to store the 25311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // property value. 25411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // out: stores the size required to hold the language 25511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // value if getLanguage() returned 25611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // TTS_PROPERTY_SIZE_TOO_SMALL, unchanged otherwise 25711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_PROPERTY_UNSUPPORTED, or TTS_SUCCESS, 25811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // or TTS_PROPERTY_SIZE_TOO_SMALL 25911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_result_t (*getProperty) 26011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine, 26111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *property, 26211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert char *value, 26311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert size_t *iosize); 26411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 26511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Synthesize the text. 26611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // As the synthesis is performed, the engine invokes the callback to notify 26711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // the TTS framework that it has filled the given buffer, and indicates how 26811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // many bytes it wrote. The callback is called repeatedly until the engine 26911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // has generated all the audio data corresponding to the text. 27011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Note about the format of the input: the text parameter may use the 27111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // following elements 27211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // and their respective attributes as defined in the SSML 1.0 specification: 27311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // * lang 27411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // * say-as: 27511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o interpret-as 27611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // * phoneme 27711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // * voice: 27811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o gender, 27911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o age, 28011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o variant, 28111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o name 28211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // * emphasis 28311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // * break: 28411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o strength, 28511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o time 28611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // * prosody: 28711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o pitch, 28811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o contour, 28911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o range, 29011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o rate, 29111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o duration, 29211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // o volume 29311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // * mark 29411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Differences between this text format and SSML are: 29511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // * full SSML documents are not supported 29611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // * namespaces are not supported 29711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // Text is coded in UTF-8. 29811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param text the UTF-8 text to synthesize 29911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param userdata pointer to be returned when the call is invoked 30011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param buffer the location where the synthesized data must be written 30111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @param bufferSize the number of bytes that can be written in buffer 30211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert // @return TTS_SUCCESS or TTS_FAILURE 30311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert android_tts_result_t (*synthesizeText) 30411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert (void *engine, 30511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert const char *text, 30611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert int8_t *buffer, 30711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert size_t bufferSize, 30811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert void *userdata); 30911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert}; 31011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 31111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifdef __cplusplus 31211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} 31311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif 31411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 31511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif /* ANDROID_TTS_H */ 316