1926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)/*
2926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2013 Apple Computer, Inc.  All rights reserved.
3926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
4926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without
5926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * modification, are permitted provided that the following conditions
6926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * are met:
7926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 1. Redistributions of source code must retain the above copyright
8926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
9926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright
10926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
11926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    documentation and/or other materials provided with the distribution.
12926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
13926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) */
25926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
26926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#ifndef PlatformSpeechSynthesizer_h
27926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#define PlatformSpeechSynthesizer_h
28926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
29a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/PlatformExport.h"
305d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)#include "platform/heap/Handle.h"
31a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/speech/PlatformSpeechSynthesisVoice.h"
327757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch#include "wtf/Vector.h"
33926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)namespace blink {
35926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
36926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)enum SpeechBoundary {
37926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    SpeechWordBoundary,
38926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    SpeechSentenceBoundary
39926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)};
40926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
41926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)class PlatformSpeechSynthesisUtterance;
427242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucciclass WebSpeechSynthesizer;
435d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)class WebSpeechSynthesizerClientImpl;
44926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
455d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)class PlatformSpeechSynthesizerClient : public GarbageCollectedMixin {
46926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)public:
475d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void didStartSpeaking(PlatformSpeechSynthesisUtterance*) = 0;
485d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void didFinishSpeaking(PlatformSpeechSynthesisUtterance*) = 0;
495d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void didPauseSpeaking(PlatformSpeechSynthesisUtterance*) = 0;
505d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void didResumeSpeaking(PlatformSpeechSynthesisUtterance*) = 0;
515d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void speakingErrorOccurred(PlatformSpeechSynthesisUtterance*) = 0;
525d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void boundaryEventOccurred(PlatformSpeechSynthesisUtterance*, SpeechBoundary, unsigned charIndex) = 0;
53926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual void voicesDidChange() = 0;
545d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)
55926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)protected:
56926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual ~PlatformSpeechSynthesizerClient() { }
57926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)};
5802772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
595d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)class PLATFORM_EXPORT PlatformSpeechSynthesizer : public GarbageCollectedFinalized<PlatformSpeechSynthesizer> {
60a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)    WTF_MAKE_NONCOPYABLE(PlatformSpeechSynthesizer);
61926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)public:
625d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    static PlatformSpeechSynthesizer* create(PlatformSpeechSynthesizerClient*);
63926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
64926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual ~PlatformSpeechSynthesizer();
6502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
665d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    const HeapVector<Member<PlatformSpeechSynthesisVoice> >& voiceList() const { return m_voiceList; }
675d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void speak(PlatformSpeechSynthesisUtterance*);
68926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual void pause();
69926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual void resume();
70926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual void cancel();
7102772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
72926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizerClient; }
73926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
745d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    void setVoiceList(HeapVector<Member<PlatformSpeechSynthesisVoice> >&);
755d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)
765d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void trace(Visitor*);
77926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
78926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)protected:
79926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    explicit PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient*);
805d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)
815d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void initializeVoiceList();
825d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)
835d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    HeapVector<Member<PlatformSpeechSynthesisVoice> > m_voiceList;
8402772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
85926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)private:
865d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    Member<PlatformSpeechSynthesizerClient> m_speechSynthesizerClient;
8753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)
887242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    OwnPtr<WebSpeechSynthesizer> m_webSpeechSynthesizer;
897242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    Member<WebSpeechSynthesizerClientImpl> m_webSpeechSynthesizerClient;
90926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)};
9102772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
92c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink
93926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
94926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#endif // PlatformSpeechSynthesizer_h
95