Package org.sodbeans.phonemic

Examples of org.sodbeans.phonemic.SpeechRequest


    @Override
    public boolean stop() {
        boolean result = speech.stop();
       
        // Ramp down to the lowest priority so that future calls aren't blocked.
        SpeechRequest dummy = new SpeechRequest();
        dummy.setPriority(SpeechPriority.LOWEST);
        consumer.setLastRequest(dummy);
        return result;
    }
View Full Code Here


        public void run() {
            try {
                Thread thisThread = Thread.currentThread();
                running = true;
                while (thisThread == blinker) {
                    SpeechRequest request = queue.take();

                    // If we aren't blocking and we aren't speaking or this is
                    // of greater priority, send off to the TTS engine.
                    // Otherwise, we ignore te request.

                    if (!block && (!speech.isSpeaking() ||
                            request.getPriority().compareTo(lastRequest.getPriority()) <= 0)) {
                        SpeechProcessor proc = request.getProcessor();
                        String textToSpeak = request.getText();

                        if (proc != null)
                            textToSpeak = proc.process();
                       
                        if (textToSpeak != null && !textToSpeak.trim().isEmpty() && speechEnabled)
                            speech.speak(textToSpeak, request.getPriority(), request.getType());

                        // We don't want to log CHARACTER requests.
                        if (request.getType() != RequestType.CHARACTER)
                            lastRequest = request;
                    }
                }
                running = false;
                blinker = null;
View Full Code Here

        consumer.start();
    }

    @Override
    public boolean respeak() {
        SpeechRequest last = consumer.getLastRequest();

        speechQueue.offer(last);
        return true;
    }
View Full Code Here

        if (priority == SpeechPriority.BLOCKING) {
            return speakBlocking(c);
        }

        String text = Character.toString(c);
        SpeechRequest request = new SpeechRequest();
        request.setText(text);
        request.setPriority(priority);
        request.setType(RequestType.CHARACTER);

        speechQueue.offer(request);
        return true;
    }
View Full Code Here

        // If it's a blocking call, handle that special case.
        if (priority == SpeechPriority.BLOCKING) {
            return speakBlocking(text, SpeechPriority.MEDIUM);
        }

        SpeechRequest request = new SpeechRequest();
        request.setText(text);
        request.setPriority(priority);
        request.setType(type);
        speechQueue.offer(request);
        return true;
    }
View Full Code Here

       
        if (proc.getPriority() == SpeechPriority.BLOCKING) {
            speakBlocking(proc.process(), proc.getPriority(), proc.getRequestType());
        }
        else {
            SpeechRequest req = new SpeechRequest();
            req.setText(proc.getText());
            req.setProcessor(proc);
            req.setPriority(proc.getPriority());
            req.setType(proc.getRequestType());
            speechQueue.offer(req);

        }

        return true;
View Full Code Here

            consumer.setBlocking(true);
            boolean result = speech.speakBlocking(text, priority, type);
            consumer.setBlocking(false);
           
            // Set this as the last request in the consumer thread.
            SpeechRequest request = new SpeechRequest();
            request.setText(text);
            request.setPriority(priority);
            request.setType(type);
            consumer.setLastRequest(request);
            return result;
        }
        else
        {
View Full Code Here

TOP

Related Classes of org.sodbeans.phonemic.SpeechRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.