150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert/* 250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Copyright (C) 2011 The Android Open Source Project 350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License"); you may not 550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * use this file except in compliance with the License. You may obtain a copy of 650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * the License at 750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0 950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 1050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Unless required by applicable law or agreed to in writing, software 1150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 1250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 1350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * License for the specific language governing permissions and limitations under 1450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * the License. 1550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 1650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringertpackage android.speech.tts; 1750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 18b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamathimport android.os.Bundle; 19b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamath 2050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert/** 21e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * Contains data required by engines to synthesize speech. This data is : 22e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * <ul> 23e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * <li>The text to synthesize</li> 24e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * <li>The synthesis locale, represented as a language, country and a variant. 25e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * The language is an ISO 639-3 letter language code, and the country is an 26e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * ISO 3166 alpha 3 code. The variant is not specified.</li> 27e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * <li>The synthesis speech rate, with 100 being the normal, and 28e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * higher values representing higher speech rates.</li> 29e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * <li>The voice pitch, with 100 being the default pitch.</li> 30e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * </ul> 3150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * 32e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * Any additional parameters sent to the text to speech service are passed in 3361dda198598e95971ca224e3bcb7393f30e45657Przemyslaw Szczepaniak * uninterpreted, see the {@code params} argument in {@link TextToSpeech#speak} 34e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * and {@link TextToSpeech#synthesizeToFile}. 3550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 36e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamathpublic final class SynthesisRequest { 3750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert private final String mText; 38b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamath private final Bundle mParams; 3950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert private String mLanguage; 4050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert private String mCountry; 4150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert private String mVariant; 4250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert private int mSpeechRate; 4350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert private int mPitch; 44653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak private int mCallerUid; 4550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 469ee8154e5910c40dc152ec08979c1e5899ddcc5aNarayan Kamath public SynthesisRequest(String text, Bundle params) { 4750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert mText = text; 48e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath // Makes a copy of params. 49b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamath mParams = new Bundle(params); 5050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert } 5150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 5250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 5350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Gets the text which should be synthesized. 5450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 5550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert public String getText() { 5650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert return mText; 5750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert } 5850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 5950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 6050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Gets the ISO 3-letter language code for the language to use. 6150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 6250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert public String getLanguage() { 6350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert return mLanguage; 6450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert } 6550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 6650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 6750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Gets the ISO 3-letter country code for the language to use. 6850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 6950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert public String getCountry() { 7050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert return mCountry; 7150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert } 7250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 7350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 7450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert * Gets the language variant to use. 7550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 7650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert public String getVariant() { 7750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert return mVariant; 7850e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert } 7950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 8050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 814bbca889df9ca76c398f3a11e871fc6ad4a4514dBjorn Bringert * Gets the speech rate to use. The normal rate is 100. 8250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 8350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert public int getSpeechRate() { 8450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert return mSpeechRate; 8550e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert } 8650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 8750e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 884bbca889df9ca76c398f3a11e871fc6ad4a4514dBjorn Bringert * Gets the pitch to use. The normal pitch is 100. 8950e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 9050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert public int getPitch() { 9150e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert return mPitch; 9250e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert } 9350e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 9450e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert /** 95b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamath * Gets the additional params, if any. 96b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamath */ 97b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamath public Bundle getParams() { 98b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamath return mParams; 99b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamath } 100b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamath 101b956f37e375bb2588208d4b5e8a40fae6fae5f86Narayan Kamath /** 102653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak * Gets the request caller Uid. 103653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak */ 104653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak public int getCallerUid() { 105653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak return mCallerUid; 106653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak } 107653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak 108653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak /** 109e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * Sets the locale for the request. 11050e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert */ 111e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath void setLanguage(String language, String country, String variant) { 112e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath mLanguage = language; 113e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath mCountry = country; 114e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath mVariant = variant; 115e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath } 11650e657bb2d005568f5dd8bc1d904d07b0d94018fBjorn Bringert 11771e0b4807797c602e7fc787d00d27c4f9c92a507Bjorn Bringert /** 118e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * Sets the speech rate. 119360eb168d6f9c967543852c7bbab370ef5d8c1bdBjorn Bringert */ 120e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath void setSpeechRate(int speechRate) { 121e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath mSpeechRate = speechRate; 122e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath } 123360eb168d6f9c967543852c7bbab370ef5d8c1bdBjorn Bringert 124360eb168d6f9c967543852c7bbab370ef5d8c1bdBjorn Bringert /** 125e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath * Sets the pitch. 12671e0b4807797c602e7fc787d00d27c4f9c92a507Bjorn Bringert */ 127e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath void setPitch(int pitch) { 128e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath mPitch = pitch; 129e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath } 130653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak 131653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak /** 132653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak * Sets Caller Uid 133653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak */ 134653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak void setCallerUid(int uid) { 135653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak mCallerUid = uid; 136653278341d76d0b23a008087ff94250ae0beb54bPrzemyslaw Szczepaniak } 137e22b69a7de0349b99d3107349d1d3aa72d62c841Narayan Kamath} 138