This source file includes following definitions.
- create
- speak
- pause
- resume
- cancel
- setVoiceList
- initializeVoiceList
#include "config.h"
#include "platform/speech/PlatformSpeechSynthesizer.h"
#include "platform/exported/WebSpeechSynthesizerClientImpl.h"
#include "platform/speech/PlatformSpeechSynthesisUtterance.h"
#include "public/platform/Platform.h"
#include "public/platform/WebSpeechSynthesisUtterance.h"
#include "public/platform/WebSpeechSynthesizer.h"
#include "public/platform/WebSpeechSynthesizerClient.h"
#include "wtf/RetainPtr.h"
namespace WebCore {
PassOwnPtr<PlatformSpeechSynthesizer> PlatformSpeechSynthesizer::create(PlatformSpeechSynthesizerClient* client)
{
OwnPtr<PlatformSpeechSynthesizer> synthesizer = adoptPtr(new PlatformSpeechSynthesizer(client));
synthesizer->initializeVoiceList();
return synthesizer.release();
}
PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient* client)
: m_speechSynthesizerClient(client)
{
m_webSpeechSynthesizerClient = adoptPtr(new WebSpeechSynthesizerClientImpl(this, client));
m_webSpeechSynthesizer = adoptPtr(blink::Platform::current()->createSpeechSynthesizer(m_webSpeechSynthesizerClient.get()));
}
PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer()
{
}
void PlatformSpeechSynthesizer::speak(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
if (!m_webSpeechSynthesizer || !m_webSpeechSynthesizerClient)
return;
m_webSpeechSynthesizer->speak(blink::WebSpeechSynthesisUtterance(utterance));
}
void PlatformSpeechSynthesizer::pause()
{
if (m_webSpeechSynthesizer.get())
m_webSpeechSynthesizer->pause();
}
void PlatformSpeechSynthesizer::resume()
{
if (m_webSpeechSynthesizer.get())
m_webSpeechSynthesizer->resume();
}
void PlatformSpeechSynthesizer::cancel()
{
if (m_webSpeechSynthesizer.get())
m_webSpeechSynthesizer->cancel();
}
void PlatformSpeechSynthesizer::setVoiceList(Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voices)
{
m_voiceList = voices;
}
void PlatformSpeechSynthesizer::initializeVoiceList()
{
if (m_webSpeechSynthesizer.get())
m_webSpeechSynthesizer->updateVoiceList();
}
}