2 * Portions Copyright 2001 Sun Microsystems, Inc.
3 * Portions Copyright 1999-2001 Language Technologies Institute,
4 * Carnegie Mellon University.
5 * All Rights Reserved. Use is subject to license terms.
7 * See the file "license.terms" for information on usage and
8 * redistribution of this file, and for a DISCLAIMER OF ALL
11 package com.sun.speech.freetts;
13 import org.w3c.dom.Document;
14 import java.io.InputStream;
17 * Minimal implementation of a FreeTTSSpeakable
19 public class FreeTTSSpeakableImpl implements FreeTTSSpeakable {
22 private InputStream inputStream;
23 volatile boolean completed = false;
24 volatile boolean cancelled = false;
29 * @param text the text to be spoken
31 public FreeTTSSpeakableImpl(String text) {
38 * @param doc the doc to be spoken
40 public FreeTTSSpeakableImpl(Document doc) {
47 * @param is the doc to be spoken
49 public FreeTTSSpeakableImpl(InputStream is) {
50 this.inputStream = is;
54 * Indicate that this speakable has been started.
56 public void started() {
60 * Indicates that this speakable has been completed.
62 public synchronized void completed() {
68 * Indicates that this speakable has been cancelled.
70 public synchronized void cancelled() {
77 * Returns true if this queue item has been
80 * @return true if it has been processed
82 public synchronized boolean isCompleted() {
87 * Waits for this speakable item to be completed.
89 * @return true if the item was completed successfully, false if
90 * the speakable was cancelled or an error occurred.
92 public synchronized boolean waitCompleted() {
96 } catch (InterruptedException ie) {
97 System.err.println( "FreeTTSSpeakableImpl:Wait interrupted");
105 * Returns <code>true</code> if the item contains plain text
106 * (not Java Speech Markup Language text).
108 * @return true if the item contains plain text
110 public boolean isPlainText() {
115 * Returns the text corresponding to this Playable.
117 * @return the Playable text
119 public String getText() {
124 * Gets the DOM document for this object.
126 * @return the DOM document for this object.
128 public Document getDocument() {
133 * Returns <code>true</code> if the item is an input stream.
135 * @return true if the item is an input stream
137 public boolean isStream() {
138 return inputStream != null;
142 * Gets the input stream.
144 * @return the input stream
146 public InputStream getInputStream() {
151 * Returns <code>true</code> if the item is a JSML document
152 * (Java Speech Markup Language).
154 * @return true if the item is a document
156 public boolean isDocument() {