Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | * use this file except in compliance with the License. You may obtain a copy of |
| 6 | * the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | * License for the specific language governing permissions and limitations under |
| 14 | * the License. |
| 15 | */ |
| 16 | package android.speech.tts; |
| 17 | |
Narayan Kamath | b956f37 | 2011-05-16 16:51:44 +0100 | [diff] [blame] | 18 | import android.os.Bundle; |
| 19 | |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 20 | /** |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 21 | * Contains data required by engines to synthesize speech. This data is : |
| 22 | * <ul> |
| 23 | * <li>The text to synthesize</li> |
| 24 | * <li>The synthesis locale, represented as a language, country and a variant. |
| 25 | * The language is an ISO 639-3 letter language code, and the country is an |
| 26 | * ISO 3166 alpha 3 code. The variant is not specified.</li> |
| 27 | * <li>The synthesis speech rate, with 100 being the normal, and |
| 28 | * higher values representing higher speech rates.</li> |
| 29 | * <li>The voice pitch, with 100 being the default pitch.</li> |
| 30 | * </ul> |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 31 | * |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 32 | * Any additional parameters sent to the text to speech service are passed in |
| 33 | * uninterpreted, see the @code{params} argument in {@link TextToSpeech#speak} |
| 34 | * and {@link TextToSpeech#synthesizeToFile}. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 35 | */ |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 36 | public final class SynthesisRequest { |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 37 | private final String mText; |
Narayan Kamath | b956f37 | 2011-05-16 16:51:44 +0100 | [diff] [blame] | 38 | private final Bundle mParams; |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 39 | private String mLanguage; |
| 40 | private String mCountry; |
| 41 | private String mVariant; |
| 42 | private int mSpeechRate; |
| 43 | private int mPitch; |
Przemyslaw Szczepaniak | 6532783 | 2013-05-31 13:12:52 +0100 | [diff] [blame] | 44 | private int mCallerUid; |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 45 | |
Narayan Kamath | 9ee8154 | 2011-06-15 18:50:23 +0100 | [diff] [blame] | 46 | public SynthesisRequest(String text, Bundle params) { |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 47 | mText = text; |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 48 | // Makes a copy of params. |
Narayan Kamath | b956f37 | 2011-05-16 16:51:44 +0100 | [diff] [blame] | 49 | mParams = new Bundle(params); |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | /** |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 53 | * Gets the text which should be synthesized. |
| 54 | */ |
| 55 | public String getText() { |
| 56 | return mText; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Gets the ISO 3-letter language code for the language to use. |
| 61 | */ |
| 62 | public String getLanguage() { |
| 63 | return mLanguage; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Gets the ISO 3-letter country code for the language to use. |
| 68 | */ |
| 69 | public String getCountry() { |
| 70 | return mCountry; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Gets the language variant to use. |
| 75 | */ |
| 76 | public String getVariant() { |
| 77 | return mVariant; |
| 78 | } |
| 79 | |
| 80 | /** |
Bjorn Bringert | 4bbca88 | 2011-04-19 18:45:25 +0100 | [diff] [blame] | 81 | * Gets the speech rate to use. The normal rate is 100. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 82 | */ |
| 83 | public int getSpeechRate() { |
| 84 | return mSpeechRate; |
| 85 | } |
| 86 | |
| 87 | /** |
Bjorn Bringert | 4bbca88 | 2011-04-19 18:45:25 +0100 | [diff] [blame] | 88 | * Gets the pitch to use. The normal pitch is 100. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 89 | */ |
| 90 | public int getPitch() { |
| 91 | return mPitch; |
| 92 | } |
| 93 | |
| 94 | /** |
Narayan Kamath | b956f37 | 2011-05-16 16:51:44 +0100 | [diff] [blame] | 95 | * Gets the additional params, if any. |
| 96 | */ |
| 97 | public Bundle getParams() { |
| 98 | return mParams; |
| 99 | } |
| 100 | |
| 101 | /** |
Przemyslaw Szczepaniak | 6532783 | 2013-05-31 13:12:52 +0100 | [diff] [blame] | 102 | * Gets the request caller Uid. |
| 103 | */ |
| 104 | public int getCallerUid() { |
| 105 | return mCallerUid; |
| 106 | } |
| 107 | |
| 108 | /** |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 109 | * Sets the locale for the request. |
Bjorn Bringert | 71e0b48 | 2011-04-15 14:37:05 +0100 | [diff] [blame] | 110 | */ |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 111 | void setLanguage(String language, String country, String variant) { |
| 112 | mLanguage = language; |
| 113 | mCountry = country; |
| 114 | mVariant = variant; |
| 115 | } |
Bjorn Bringert | 71e0b48 | 2011-04-15 14:37:05 +0100 | [diff] [blame] | 116 | |
| 117 | /** |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 118 | * Sets the speech rate. |
Bjorn Bringert | 360eb16 | 2011-04-19 09:20:35 +0100 | [diff] [blame] | 119 | */ |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 120 | void setSpeechRate(int speechRate) { |
| 121 | mSpeechRate = speechRate; |
| 122 | } |
Bjorn Bringert | 360eb16 | 2011-04-19 09:20:35 +0100 | [diff] [blame] | 123 | |
| 124 | /** |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 125 | * Sets the pitch. |
Bjorn Bringert | 50e657b | 2011-03-08 16:00:40 +0000 | [diff] [blame] | 126 | */ |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 127 | void setPitch(int pitch) { |
| 128 | mPitch = pitch; |
| 129 | } |
Przemyslaw Szczepaniak | 6532783 | 2013-05-31 13:12:52 +0100 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * Sets Caller Uid |
| 133 | */ |
| 134 | void setCallerUid(int uid) { |
| 135 | mCallerUid = uid; |
| 136 | } |
Narayan Kamath | e22b69a | 2011-06-08 11:41:47 +0100 | [diff] [blame] | 137 | } |