#ifndef SpeechSynthesis_h
#define SpeechSynthesis_h
#if ENABLE(SPEECH_SYNTHESIS)
#include "PlatformSpeechSynthesisUtterance.h"
#include "PlatformSpeechSynthesizer.h"
#include "SpeechSynthesisUtterance.h"
#include "SpeechSynthesisVoice.h"
#include <wtf/Deque.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class PlatformSpeechSynthesizerClient;
class SpeechSynthesisVoice;
class SpeechSynthesis : public PlatformSpeechSynthesizerClient, public RefCounted<SpeechSynthesis> {
public:
static PassRefPtr<SpeechSynthesis> create();
bool pending() const;
bool speaking() const;
bool paused() const;
void speak(SpeechSynthesisUtterance*);
void cancel();
void pause();
void resume();
const Vector<RefPtr<SpeechSynthesisVoice> >& getVoices();
void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>);
private:
SpeechSynthesis();
virtual void voicesDidChange() OVERRIDE;
virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>) OVERRIDE;
virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>, SpeechBoundary, unsigned charIndex) OVERRIDE;
void startSpeakingImmediately(SpeechSynthesisUtterance*);
void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred);
void fireEvent(const AtomicString& type, SpeechSynthesisUtterance*, unsigned long charIndex, const String& name);
OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer;
Vector<RefPtr<SpeechSynthesisVoice> > m_voiceList;
SpeechSynthesisUtterance* m_currentSpeechUtterance;
Deque<RefPtr<SpeechSynthesisUtterance> > m_utteranceQueue;
bool m_isPaused;
};
}
#endif // ENABLE(SPEECH_SYNTHESIS)
#endif // SpeechSynthesisEvent_h