Debian Codegraph @

core/java/android/speech/tts/SynthesisRequest.java

raw symbols SCIP
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
18 import android.os.Bundle;
19
20 /**
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 name of the voice requested for this synthesis. May be empty if
28 * the client uses {@link TextToSpeech#setLanguage} instead of
29 * {@link TextToSpeech#setVoice}</li>
30 * <li>The synthesis speech rate, with 100 being the normal, and
31 * higher values representing higher speech rates.</li>
32 * <li>The voice pitch, with 100 being the default pitch.</li>
33 * </ul>
34 *
35 * Any additional parameters sent to the text to speech service are passed in
36 * uninterpreted, see the {@code params} argument in {@link TextToSpeech#speak}
37 * and {@link TextToSpeech#synthesizeToFile}.
38 */
39 public final class SynthesisRequest {
40 private final CharSequence mText;
41 private final Bundle mParams;
42 private String mVoiceName;
43 private String mLanguage;
44 private String mCountry;
45 private String mVariant;
46 private int mSpeechRate;
47 private int mPitch;
48 private int mCallerUid;
49
50 public SynthesisRequest(String text, Bundle params) {
51 mText = text;
52 // Makes a copy of params.
53 mParams = new Bundle(params);
54 }
55
56 public SynthesisRequest(CharSequence text, Bundle params) {
57 mText = text;
58 // Makes a copy of params.
59 mParams = new Bundle(params);
60 }
61
62 /**
63 * Gets the text which should be synthesized.
64 * @deprecated As of API level 21, replaced by {@link #getCharSequenceText}.
65 */
66 @Deprecated
67 public String getText() {
68 return mText.toString();
69 }
70
71 /**
72 * Gets the text which should be synthesized.
73 */
74 public CharSequence getCharSequenceText() {
75 return mText;
76 }
77
78 /**
79 * Gets the name of the voice to use.
80 */
81 public String getVoiceName() {
82 return mVoiceName;
83 }
84
85 /**
86 * Gets the ISO 3-letter language code for the language to use.
87 */
88 public String getLanguage() {
89 return mLanguage;
90 }
91
92 /**
93 * Gets the ISO 3-letter country code for the language to use.
94 */
95 public String getCountry() {
96 return mCountry;
97 }
98
99 /**
100 * Gets the language variant to use.
101 */
102 public String getVariant() {
103 return mVariant;
104 }
105
106 /**
107 * Gets the speech rate to use. The normal rate is 100.
108 */
109 public int getSpeechRate() {
110 return mSpeechRate;
111 }
112
113 /**
114 * Gets the pitch to use. The normal pitch is 100.
115 */
116 public int getPitch() {
117 return mPitch;
118 }
119
120 /**
121 * Gets the additional params, if any.
122 */
123 public Bundle getParams() {
124 return mParams;
125 }
126
127 /**
128 * Gets the request caller Uid.
129 */
130 public int getCallerUid() {
131 return mCallerUid;
132 }
133
134 /**
135 * Sets the locale for the request.
136 */
137 void setLanguage(String language, String country, String variant) {
138 mLanguage = language;
139 mCountry = country;
140 mVariant = variant;
141 }
142
143 /**
144 * Sets the voice name for the request.
145 */
146 void setVoiceName(String voiceName) {
147 mVoiceName = voiceName;
148 }
149
150 /**
151 * Sets the speech rate.
152 */
153 void setSpeechRate(int speechRate) {
154 mSpeechRate = speechRate;
155 }
156
157 /**
158 * Sets the pitch.
159 */
160 void setPitch(int pitch) {
161 mPitch = pitch;
162 }
163
164 /**
165 * Sets Caller Uid
166 */
167 void setCallerUid(int uid) {
168 mCallerUid = uid;
169 }
170 }