blob: 6398d3d27e2633e5f6c0c1a66e9446a75aace285 [file] [log] [blame]
Bjorn Bringert50e657b2011-03-08 16:00:40 +00001/*
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 */
16package android.speech.tts;
17
Narayan Kamathb956f372011-05-16 16:51:44 +010018import android.os.Bundle;
19
Bjorn Bringert50e657b2011-03-08 16:00:40 +000020/**
Narayan Kamathe22b69a2011-06-08 11:41:47 +010021 * 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 Bringert50e657b2011-03-08 16:00:40 +000031 *
Narayan Kamathe22b69a2011-06-08 11:41:47 +010032 * 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 Bringert50e657b2011-03-08 16:00:40 +000035 */
Narayan Kamathe22b69a2011-06-08 11:41:47 +010036public final class SynthesisRequest {
Bjorn Bringert50e657b2011-03-08 16:00:40 +000037 private final String mText;
Narayan Kamathb956f372011-05-16 16:51:44 +010038 private final Bundle mParams;
Bjorn Bringert50e657b2011-03-08 16:00:40 +000039 private String mLanguage;
40 private String mCountry;
41 private String mVariant;
42 private int mSpeechRate;
43 private int mPitch;
44
Narayan Kamath9ee81542011-06-15 18:50:23 +010045 public SynthesisRequest(String text, Bundle params) {
Bjorn Bringert50e657b2011-03-08 16:00:40 +000046 mText = text;
Narayan Kamathe22b69a2011-06-08 11:41:47 +010047 // Makes a copy of params.
Narayan Kamathb956f372011-05-16 16:51:44 +010048 mParams = new Bundle(params);
Bjorn Bringert50e657b2011-03-08 16:00:40 +000049 }
50
51 /**
Bjorn Bringert50e657b2011-03-08 16:00:40 +000052 * Gets the text which should be synthesized.
53 */
54 public String getText() {
55 return mText;
56 }
57
58 /**
59 * Gets the ISO 3-letter language code for the language to use.
60 */
61 public String getLanguage() {
62 return mLanguage;
63 }
64
65 /**
66 * Gets the ISO 3-letter country code for the language to use.
67 */
68 public String getCountry() {
69 return mCountry;
70 }
71
72 /**
73 * Gets the language variant to use.
74 */
75 public String getVariant() {
76 return mVariant;
77 }
78
79 /**
Bjorn Bringert4bbca882011-04-19 18:45:25 +010080 * Gets the speech rate to use. The normal rate is 100.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000081 */
82 public int getSpeechRate() {
83 return mSpeechRate;
84 }
85
86 /**
Bjorn Bringert4bbca882011-04-19 18:45:25 +010087 * Gets the pitch to use. The normal pitch is 100.
Bjorn Bringert50e657b2011-03-08 16:00:40 +000088 */
89 public int getPitch() {
90 return mPitch;
91 }
92
93 /**
Narayan Kamathb956f372011-05-16 16:51:44 +010094 * Gets the additional params, if any.
95 */
96 public Bundle getParams() {
97 return mParams;
98 }
99
100 /**
Narayan Kamathe22b69a2011-06-08 11:41:47 +0100101 * Sets the locale for the request.
Bjorn Bringert71e0b482011-04-15 14:37:05 +0100102 */
Narayan Kamathe22b69a2011-06-08 11:41:47 +0100103 void setLanguage(String language, String country, String variant) {
104 mLanguage = language;
105 mCountry = country;
106 mVariant = variant;
107 }
Bjorn Bringert71e0b482011-04-15 14:37:05 +0100108
109 /**
Narayan Kamathe22b69a2011-06-08 11:41:47 +0100110 * Sets the speech rate.
Bjorn Bringert360eb162011-04-19 09:20:35 +0100111 */
Narayan Kamathe22b69a2011-06-08 11:41:47 +0100112 void setSpeechRate(int speechRate) {
113 mSpeechRate = speechRate;
114 }
Bjorn Bringert360eb162011-04-19 09:20:35 +0100115
116 /**
Narayan Kamathe22b69a2011-06-08 11:41:47 +0100117 * Sets the pitch.
Bjorn Bringert50e657b2011-03-08 16:00:40 +0000118 */
Narayan Kamathe22b69a2011-06-08 11:41:47 +0100119 void setPitch(int pitch) {
120 mPitch = pitch;
121 }
122}