https://bugs.webkit.org/show_bug.cgi?id=111695
Reviewed by Adam Barth.
Source/Platform:
Exposes a platform API that the embedder can implement to
provide speech synthesis for the Chromium port.
* Platform.gypi:
* chromium/public/Platform.h:
(WebKit):
(Platform):
(WebKit::Platform::speechSynthesizer):
* chromium/public/WebSpeechSynthesisUtterance.h: Added.
(WebKit):
(WebSpeechSynthesisUtterance):
(WebKit::WebSpeechSynthesisUtterance::WebSpeechSynthesisUtterance):
(WebKit::WebSpeechSynthesisUtterance::~WebSpeechSynthesisUtterance):
(WebKit::WebSpeechSynthesisUtterance::operator=):
(WebKit::WebSpeechSynthesisUtterance::isNull):
* chromium/public/WebSpeechSynthesisVoice.h: Added.
(WebCore):
(WebKit):
(WebSpeechSynthesisVoice):
(WebKit::WebSpeechSynthesisVoice::WebSpeechSynthesisVoice):
(WebKit::WebSpeechSynthesisVoice::~WebSpeechSynthesisVoice):
(WebKit::WebSpeechSynthesisVoice::operator=):
* chromium/public/WebSpeechSynthesizer.h: Added.
(WebKit):
(WebSpeechSynthesizer):
(WebKit::WebSpeechSynthesizer::~WebSpeechSynthesizer):
* chromium/public/WebSpeechSynthesizerClient.h: Added.
(WebKit):
(WebSpeechSynthesizerClient):
(WebKit::WebSpeechSynthesizerClient::~WebSpeechSynthesizerClient):
Source/WebCore:
Straightforward implementation of speech synthesis
for Chromium by exposing interfaces for the platform
to implement.
* Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::boundaryEventOccurred):
(WebCore::SpeechSynthesis::didStartSpeaking):
(WebCore::SpeechSynthesis::didPauseSpeaking):
(WebCore::SpeechSynthesis::didResumeSpeaking):
(WebCore::SpeechSynthesis::didFinishSpeaking):
(WebCore::SpeechSynthesis::speakingErrorOccurred):
(WebCore):
* Modules/speech/SpeechSynthesis.h:
(SpeechSynthesis):
* Modules/speech/SpeechSynthesisUtterance.cpp:
(WebCore::SpeechSynthesisUtterance::SpeechSynthesisUtterance):
(WebCore):
(WebCore::SpeechSynthesisUtterance::~SpeechSynthesisUtterance):
(WebCore::SpeechSynthesisUtterance::setVoice):
* Modules/speech/SpeechSynthesisUtterance.h:
(SpeechSynthesisUtterance):
(WebCore::SpeechSynthesisUtterance::text):
(WebCore::SpeechSynthesisUtterance::setText):
(WebCore::SpeechSynthesisUtterance::lang):
(WebCore::SpeechSynthesisUtterance::setLang):
(WebCore::SpeechSynthesisUtterance::volume):
(WebCore::SpeechSynthesisUtterance::setVolume):
(WebCore::SpeechSynthesisUtterance::rate):
(WebCore::SpeechSynthesisUtterance::setRate):
(WebCore::SpeechSynthesisUtterance::pitch):
(WebCore::SpeechSynthesisUtterance::setPitch):
(WebCore::SpeechSynthesisUtterance::startTime):
(WebCore::SpeechSynthesisUtterance::setStartTime):
(WebCore::SpeechSynthesisUtterance::platformUtterance):
* Modules/speech/SpeechSynthesisVoice.h:
(WebCore::SpeechSynthesisVoice::~SpeechSynthesisVoice):
* WebCore.exp.in:
* WebCore.gypi:
* platform/PlatformSpeechSynthesis.h:
(PlatformSpeechSynthesis):
* platform/PlatformSpeechSynthesisUtterance.cpp:
(WebCore):
(WebCore::PlatformSpeechSynthesisUtterance::create):
* platform/PlatformSpeechSynthesisUtterance.h:
(PlatformSpeechSynthesisUtterance):
(WebCore::PlatformSpeechSynthesisUtterance::setClient):
* platform/PlatformSpeechSynthesisVoice.cpp:
(WebCore):
(WebCore::PlatformSpeechSynthesisVoice::create):
(WebCore::PlatformSpeechSynthesisVoice::PlatformSpeechSynthesisVoice):
* platform/PlatformSpeechSynthesisVoice.h:
(PlatformSpeechSynthesisVoice):
(WebCore::PlatformSpeechSynthesisVoice::setVoiceURI):
(WebCore::PlatformSpeechSynthesisVoice::setName):
(WebCore::PlatformSpeechSynthesisVoice::setLang):
(WebCore::PlatformSpeechSynthesisVoice::setLocalService):
(WebCore::PlatformSpeechSynthesisVoice::setIsDefault):
* platform/PlatformSpeechSynthesizer.cpp:
(WebCore::PlatformSpeechSynthesizer::create):
(WebCore::PlatformSpeechSynthesizer::setVoiceList):
(WebCore):
* platform/PlatformSpeechSynthesizer.h:
(WebKit):
(PlatformSpeechSynthesizerClient):
(PlatformSpeechSynthesizer):
* platform/chromium/PlatformSpeechSynthesizerChromium.cpp: Added.
(WebCore):
(WebCore::PlatformSpeechSynthesizer::PlatformSpeechSynthesizer):
(WebCore::PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer):
(WebCore::PlatformSpeechSynthesizer::initializeVoiceList):
(WebCore::PlatformSpeechSynthesizer::speak):
(WebCore::PlatformSpeechSynthesizer::pause):
(WebCore::PlatformSpeechSynthesizer::resume):
(WebCore::PlatformSpeechSynthesizer::cancel):
* platform/chromium/support/WebSpeechSynthesisUtterance.cpp: Added.
(WebKit):
(WebKit::WebSpeechSynthesisUtterance::WebSpeechSynthesisUtterance):
(WebKit::WebSpeechSynthesisUtterance::operator=):
(WebKit::WebSpeechSynthesisUtterance::assign):
(WebKit::WebSpeechSynthesisUtterance::reset):
(WebKit::WebSpeechSynthesisUtterance::operator PassRefPtr<PlatformSpeechSynthesisUtterance>):
(WebKit::WebSpeechSynthesisUtterance::operator PlatformSpeechSynthesisUtterance*):
(WebKit::WebSpeechSynthesisUtterance::text):
(WebKit::WebSpeechSynthesisUtterance::lang):
(WebKit::WebSpeechSynthesisUtterance::voice):
(WebKit::WebSpeechSynthesisUtterance::volume):
(WebKit::WebSpeechSynthesisUtterance::rate):
(WebKit::WebSpeechSynthesisUtterance::pitch):
(WebKit::WebSpeechSynthesisUtterance::startTime):
* platform/chromium/support/WebSpeechSynthesisVoice.cpp: Added.
(WebKit):
(WebKit::WebSpeechSynthesisVoice::assign):
(WebKit::WebSpeechSynthesisVoice::reset):
(WebKit::WebSpeechSynthesisVoice::setVoiceURI):
(WebKit::WebSpeechSynthesisVoice::setName):
(WebKit::WebSpeechSynthesisVoice::setLanguage):
(WebKit::WebSpeechSynthesisVoice::setIsLocalService):
(WebKit::WebSpeechSynthesisVoice::setIsDefault):
(WebKit::WebSpeechSynthesisVoice::operator PassRefPtr<WebCore::PlatformSpeechSynthesisVoice>):
* platform/chromium/support/WebSpeechSynthesizerClientImpl.cpp: Added.
(WebCore):
(WebCore::WebSpeechSynthesizerClientImpl::WebSpeechSynthesizerClientImpl):
(WebCore::WebSpeechSynthesizerClientImpl::~WebSpeechSynthesizerClientImpl):
(WebCore::WebSpeechSynthesizerClientImpl::setVoiceList):
(WebCore::WebSpeechSynthesizerClientImpl::didStartSpeaking):
(WebCore::WebSpeechSynthesizerClientImpl::didFinishSpeaking):
(WebCore::WebSpeechSynthesizerClientImpl::didPauseSpeaking):
(WebCore::WebSpeechSynthesizerClientImpl::didResumeSpeaking):
(WebCore::WebSpeechSynthesizerClientImpl::speakingErrorOccurred):
(WebCore::WebSpeechSynthesizerClientImpl::wordBoundaryEventOccurred):
(WebCore::WebSpeechSynthesizerClientImpl::sentenceBoundaryEventOccurred):
* platform/chromium/support/WebSpeechSynthesizerClientImpl.h: Added.
(WebCore):
(WebSpeechSynthesizerClientImpl):
* platform/mac/PlatformSpeechSynthesizerMac.mm:
(-[WebSpeechSynthesisWrapper speakUtterance:WebCore::]):
(-[WebSpeechSynthesisWrapper speechSynthesizer:didFinishSpeaking:]):
(WebCore::PlatformSpeechSynthesizer::PlatformSpeechSynthesizer):
(WebCore):
(WebCore::PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer):
(WebCore::PlatformSpeechSynthesizer::speak):
* platform/mock/PlatformSpeechSynthesizerMock.cpp:
(WebCore::PlatformSpeechSynthesizerMock::PlatformSpeechSynthesizerMock):
(WebCore::PlatformSpeechSynthesizerMock::speakingFinished):
(WebCore::PlatformSpeechSynthesizerMock::speak):
* platform/mock/PlatformSpeechSynthesizerMock.h:
(PlatformSpeechSynthesizerMock):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@146724
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-03-23 Dominic Mazzoni <dmazzoni@google.com>
+
+ Implement Web Speech Synthesis for Chromium
+ https://bugs.webkit.org/show_bug.cgi?id=111695
+
+ Reviewed by Adam Barth.
+
+ Exposes a platform API that the embedder can implement to
+ provide speech synthesis for the Chromium port.
+
+ * Platform.gypi:
+ * chromium/public/Platform.h:
+ (WebKit):
+ (Platform):
+ (WebKit::Platform::speechSynthesizer):
+ * chromium/public/WebSpeechSynthesisUtterance.h: Added.
+ (WebKit):
+ (WebSpeechSynthesisUtterance):
+ (WebKit::WebSpeechSynthesisUtterance::WebSpeechSynthesisUtterance):
+ (WebKit::WebSpeechSynthesisUtterance::~WebSpeechSynthesisUtterance):
+ (WebKit::WebSpeechSynthesisUtterance::operator=):
+ (WebKit::WebSpeechSynthesisUtterance::isNull):
+ * chromium/public/WebSpeechSynthesisVoice.h: Added.
+ (WebCore):
+ (WebKit):
+ (WebSpeechSynthesisVoice):
+ (WebKit::WebSpeechSynthesisVoice::WebSpeechSynthesisVoice):
+ (WebKit::WebSpeechSynthesisVoice::~WebSpeechSynthesisVoice):
+ (WebKit::WebSpeechSynthesisVoice::operator=):
+ * chromium/public/WebSpeechSynthesizer.h: Added.
+ (WebKit):
+ (WebSpeechSynthesizer):
+ (WebKit::WebSpeechSynthesizer::~WebSpeechSynthesizer):
+ * chromium/public/WebSpeechSynthesizerClient.h: Added.
+ (WebKit):
+ (WebSpeechSynthesizerClient):
+ (WebKit::WebSpeechSynthesizerClient::~WebSpeechSynthesizerClient):
+
2013-03-22 David Grogan <dgrogan@chromium.org>
IndexedDB: Histogram available disk space on attempt to open database
'chromium/public/WebSocketStreamHandle.h',
'chromium/public/WebSocketStreamHandleClient.h',
'chromium/public/WebSolidColorLayer.h',
+ 'chromium/public/WebSpeechSynthesizer.h',
+ 'chromium/public/WebSpeechSynthesizerClient.h',
+ 'chromium/public/WebSpeechSynthesisUtterance.h',
+ 'chromium/public/WebSpeechSynthesisVoice.h',
'chromium/public/WebStorageArea.h',
'chromium/public/WebStorageNamespace.h',
'chromium/public/WebString.h',
#include "WebGamepads.h"
#include "WebGraphicsContext3D.h"
#include "WebLocalizedString.h"
+#include "WebSpeechSynthesizer.h"
#include "WebString.h"
#include "WebVector.h"
class WebRTCPeerConnectionHandlerClient;
class WebSandboxSupport;
class WebSocketStreamHandle;
+class WebSpeechSynthesizer;
+class WebSpeechSynthesizerClient;
class WebStorageNamespace;
class WebUnitTestSupport;
class WebThemeEngine;
// Must return non-null.
virtual WebHyphenator* hyphenator() { return 0; }
+ // May return null.
+ virtual WebSpeechSynthesizer* createSpeechSynthesizer(WebSpeechSynthesizerClient*) { return 0; }
// Audio --------------------------------------------------------------
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSpeechSynthesisUtterance_h
+#define WebSpeechSynthesisUtterance_h
+
+#include "WebCommon.h"
+#include "WebPrivatePtr.h"
+#include "WebString.h"
+
+namespace WebCore { class PlatformSpeechSynthesisUtterance; }
+
+namespace WebKit {
+
+class WebSpeechSynthesisUtterance {
+public:
+ WebSpeechSynthesisUtterance() { }
+ WebSpeechSynthesisUtterance(const WebSpeechSynthesisUtterance& other) { assign(other); }
+ ~WebSpeechSynthesisUtterance() { reset(); }
+
+ WebSpeechSynthesisUtterance& operator=(const WebSpeechSynthesisUtterance& other)
+ {
+ assign(other);
+ return *this;
+ }
+
+ WEBKIT_EXPORT void assign(const WebSpeechSynthesisUtterance&);
+ WEBKIT_EXPORT void reset();
+ bool isNull() const { return m_private.isNull(); }
+
+ WEBKIT_EXPORT WebString text() const;
+ WEBKIT_EXPORT WebString lang() const;
+ WEBKIT_EXPORT WebString voice() const;
+
+ // As defined in: https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
+ WEBKIT_EXPORT float volume() const; // 0...1, 1 is default
+ WEBKIT_EXPORT float rate() const; // 0.1...10, 1 is default
+ WEBKIT_EXPORT float pitch() const; // 0...2, 1 is default
+
+ WEBKIT_EXPORT double startTime() const; // In seconds.
+
+#if WEBKIT_IMPLEMENTATION
+ WebSpeechSynthesisUtterance(const PassRefPtr<WebCore::PlatformSpeechSynthesisUtterance>&);
+ WebSpeechSynthesisUtterance& operator=(WebCore::PlatformSpeechSynthesisUtterance*);
+ operator PassRefPtr<WebCore::PlatformSpeechSynthesisUtterance>() const;
+ operator WebCore::PlatformSpeechSynthesisUtterance*() const;
+#endif
+
+private:
+ WebPrivatePtr<WebCore::PlatformSpeechSynthesisUtterance> m_private;
+};
+
+} // namespace WebKit
+
+#endif // WebSpeechSynthesisUtterance_h
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSpeechSynthesisVoice_h
+#define WebSpeechSynthesisVoice_h
+
+#include "WebCommon.h"
+#include "WebPrivatePtr.h"
+#include "WebString.h"
+
+namespace WebCore {
+class PlatformSpeechSynthesisVoice;
+}
+
+namespace WebKit {
+
+class WebSpeechSynthesisVoice {
+public:
+ WebSpeechSynthesisVoice() { }
+ WebSpeechSynthesisVoice(const WebSpeechSynthesisVoice& other) { assign(other); }
+ ~WebSpeechSynthesisVoice() { reset(); }
+
+ WebSpeechSynthesisVoice& operator=(const WebSpeechSynthesisVoice& other)
+ {
+ assign(other);
+ return *this;
+ }
+
+ WEBKIT_EXPORT void assign(const WebSpeechSynthesisVoice&);
+ WEBKIT_EXPORT void reset();
+
+ WEBKIT_EXPORT void setVoiceURI(const WebString&);
+ WEBKIT_EXPORT void setName(const WebString&);
+ WEBKIT_EXPORT void setLanguage(const WebString&);
+ WEBKIT_EXPORT void setIsLocalService(bool);
+ WEBKIT_EXPORT void setIsDefault(bool);
+
+#if WEBKIT_IMPLEMENTATION
+ operator WTF::PassRefPtr<WebCore::PlatformSpeechSynthesisVoice>() const;
+#endif
+
+private:
+ WebPrivatePtr<WebCore::PlatformSpeechSynthesisVoice> m_private;
+};
+
+} // namespace WebKit
+
+#endif // WebSpeechSynthesisVoice_h
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSpeechSynthesizer_h
+#define WebSpeechSynthesizer_h
+
+#include "WebCommon.h"
+
+namespace WebKit {
+
+class WebSpeechSynthesizerClient;
+class WebSpeechSynthesisUtterance;
+
+class WebSpeechSynthesizer {
+public:
+ virtual ~WebSpeechSynthesizer() { }
+
+ virtual void updateVoiceList() = 0;
+
+ // OK to call with more than one utterance, will queue.
+ virtual void speak(const WebSpeechSynthesisUtterance&) = 0;
+
+ virtual void pause() = 0;
+ virtual void resume() = 0;
+ virtual void cancel() = 0;
+};
+
+} // namespace WebKit
+
+#endif // WebSpeechSynthesizer_h
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSpeechSynthesizerClient_h
+#define WebSpeechSynthesizerClient_h
+
+#include "WebSpeechSynthesisUtterance.h"
+#include "WebSpeechSynthesisVoice.h"
+#include "WebVector.h"
+
+namespace WebKit {
+
+class WebSpeechSynthesizerClient {
+public:
+ virtual ~WebSpeechSynthesizerClient() { }
+
+ virtual void setVoiceList(const WebVector<WebSpeechSynthesisVoice>&) = 0;
+ virtual void didStartSpeaking(const WebSpeechSynthesisUtterance&) = 0;
+ virtual void didPauseSpeaking(const WebSpeechSynthesisUtterance&) = 0;
+ virtual void didResumeSpeaking(const WebSpeechSynthesisUtterance&) = 0;
+ virtual void didFinishSpeaking(const WebSpeechSynthesisUtterance&) = 0;
+ virtual void speakingErrorOccurred(const WebSpeechSynthesisUtterance&) = 0;
+ virtual void wordBoundaryEventOccurred(const WebSpeechSynthesisUtterance&, unsigned charIndex) = 0;
+ virtual void sentenceBoundaryEventOccurred(const WebSpeechSynthesisUtterance&, unsigned charIndex) = 0;
+};
+
+} // namespace WebKit
+
+#endif // WebSpeechSynthesizerClient_h
+2013-03-23 Dominic Mazzoni <dmazzoni@google.com>
+
+ Implement Web Speech Synthesis for Chromium
+ https://bugs.webkit.org/show_bug.cgi?id=111695
+
+ Reviewed by Adam Barth.
+
+ Straightforward implementation of speech synthesis
+ for Chromium by exposing interfaces for the platform
+ to implement.
+
+ * Modules/speech/SpeechSynthesis.cpp:
+ (WebCore::SpeechSynthesis::boundaryEventOccurred):
+ (WebCore::SpeechSynthesis::didStartSpeaking):
+ (WebCore::SpeechSynthesis::didPauseSpeaking):
+ (WebCore::SpeechSynthesis::didResumeSpeaking):
+ (WebCore::SpeechSynthesis::didFinishSpeaking):
+ (WebCore::SpeechSynthesis::speakingErrorOccurred):
+ (WebCore):
+ * Modules/speech/SpeechSynthesis.h:
+ (SpeechSynthesis):
+ * Modules/speech/SpeechSynthesisUtterance.cpp:
+ (WebCore::SpeechSynthesisUtterance::SpeechSynthesisUtterance):
+ (WebCore):
+ (WebCore::SpeechSynthesisUtterance::~SpeechSynthesisUtterance):
+ (WebCore::SpeechSynthesisUtterance::setVoice):
+ * Modules/speech/SpeechSynthesisUtterance.h:
+ (SpeechSynthesisUtterance):
+ (WebCore::SpeechSynthesisUtterance::text):
+ (WebCore::SpeechSynthesisUtterance::setText):
+ (WebCore::SpeechSynthesisUtterance::lang):
+ (WebCore::SpeechSynthesisUtterance::setLang):
+ (WebCore::SpeechSynthesisUtterance::volume):
+ (WebCore::SpeechSynthesisUtterance::setVolume):
+ (WebCore::SpeechSynthesisUtterance::rate):
+ (WebCore::SpeechSynthesisUtterance::setRate):
+ (WebCore::SpeechSynthesisUtterance::pitch):
+ (WebCore::SpeechSynthesisUtterance::setPitch):
+ (WebCore::SpeechSynthesisUtterance::startTime):
+ (WebCore::SpeechSynthesisUtterance::setStartTime):
+ (WebCore::SpeechSynthesisUtterance::platformUtterance):
+ * Modules/speech/SpeechSynthesisVoice.h:
+ (WebCore::SpeechSynthesisVoice::~SpeechSynthesisVoice):
+ * WebCore.exp.in:
+ * WebCore.gypi:
+ * platform/PlatformSpeechSynthesis.h:
+ (PlatformSpeechSynthesis):
+ * platform/PlatformSpeechSynthesisUtterance.cpp:
+ (WebCore):
+ (WebCore::PlatformSpeechSynthesisUtterance::create):
+ * platform/PlatformSpeechSynthesisUtterance.h:
+ (PlatformSpeechSynthesisUtterance):
+ (WebCore::PlatformSpeechSynthesisUtterance::setClient):
+ * platform/PlatformSpeechSynthesisVoice.cpp:
+ (WebCore):
+ (WebCore::PlatformSpeechSynthesisVoice::create):
+ (WebCore::PlatformSpeechSynthesisVoice::PlatformSpeechSynthesisVoice):
+ * platform/PlatformSpeechSynthesisVoice.h:
+ (PlatformSpeechSynthesisVoice):
+ (WebCore::PlatformSpeechSynthesisVoice::setVoiceURI):
+ (WebCore::PlatformSpeechSynthesisVoice::setName):
+ (WebCore::PlatformSpeechSynthesisVoice::setLang):
+ (WebCore::PlatformSpeechSynthesisVoice::setLocalService):
+ (WebCore::PlatformSpeechSynthesisVoice::setIsDefault):
+ * platform/PlatformSpeechSynthesizer.cpp:
+ (WebCore::PlatformSpeechSynthesizer::create):
+ (WebCore::PlatformSpeechSynthesizer::setVoiceList):
+ (WebCore):
+ * platform/PlatformSpeechSynthesizer.h:
+ (WebKit):
+ (PlatformSpeechSynthesizerClient):
+ (PlatformSpeechSynthesizer):
+ * platform/chromium/PlatformSpeechSynthesizerChromium.cpp: Added.
+ (WebCore):
+ (WebCore::PlatformSpeechSynthesizer::PlatformSpeechSynthesizer):
+ (WebCore::PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer):
+ (WebCore::PlatformSpeechSynthesizer::initializeVoiceList):
+ (WebCore::PlatformSpeechSynthesizer::speak):
+ (WebCore::PlatformSpeechSynthesizer::pause):
+ (WebCore::PlatformSpeechSynthesizer::resume):
+ (WebCore::PlatformSpeechSynthesizer::cancel):
+ * platform/chromium/support/WebSpeechSynthesisUtterance.cpp: Added.
+ (WebKit):
+ (WebKit::WebSpeechSynthesisUtterance::WebSpeechSynthesisUtterance):
+ (WebKit::WebSpeechSynthesisUtterance::operator=):
+ (WebKit::WebSpeechSynthesisUtterance::assign):
+ (WebKit::WebSpeechSynthesisUtterance::reset):
+ (WebKit::WebSpeechSynthesisUtterance::operator PassRefPtr<PlatformSpeechSynthesisUtterance>):
+ (WebKit::WebSpeechSynthesisUtterance::operator PlatformSpeechSynthesisUtterance*):
+ (WebKit::WebSpeechSynthesisUtterance::text):
+ (WebKit::WebSpeechSynthesisUtterance::lang):
+ (WebKit::WebSpeechSynthesisUtterance::voice):
+ (WebKit::WebSpeechSynthesisUtterance::volume):
+ (WebKit::WebSpeechSynthesisUtterance::rate):
+ (WebKit::WebSpeechSynthesisUtterance::pitch):
+ (WebKit::WebSpeechSynthesisUtterance::startTime):
+ * platform/chromium/support/WebSpeechSynthesisVoice.cpp: Added.
+ (WebKit):
+ (WebKit::WebSpeechSynthesisVoice::assign):
+ (WebKit::WebSpeechSynthesisVoice::reset):
+ (WebKit::WebSpeechSynthesisVoice::setVoiceURI):
+ (WebKit::WebSpeechSynthesisVoice::setName):
+ (WebKit::WebSpeechSynthesisVoice::setLanguage):
+ (WebKit::WebSpeechSynthesisVoice::setIsLocalService):
+ (WebKit::WebSpeechSynthesisVoice::setIsDefault):
+ (WebKit::WebSpeechSynthesisVoice::operator PassRefPtr<WebCore::PlatformSpeechSynthesisVoice>):
+ * platform/chromium/support/WebSpeechSynthesizerClientImpl.cpp: Added.
+ (WebCore):
+ (WebCore::WebSpeechSynthesizerClientImpl::WebSpeechSynthesizerClientImpl):
+ (WebCore::WebSpeechSynthesizerClientImpl::~WebSpeechSynthesizerClientImpl):
+ (WebCore::WebSpeechSynthesizerClientImpl::setVoiceList):
+ (WebCore::WebSpeechSynthesizerClientImpl::didStartSpeaking):
+ (WebCore::WebSpeechSynthesizerClientImpl::didFinishSpeaking):
+ (WebCore::WebSpeechSynthesizerClientImpl::didPauseSpeaking):
+ (WebCore::WebSpeechSynthesizerClientImpl::didResumeSpeaking):
+ (WebCore::WebSpeechSynthesizerClientImpl::speakingErrorOccurred):
+ (WebCore::WebSpeechSynthesizerClientImpl::wordBoundaryEventOccurred):
+ (WebCore::WebSpeechSynthesizerClientImpl::sentenceBoundaryEventOccurred):
+ * platform/chromium/support/WebSpeechSynthesizerClientImpl.h: Added.
+ (WebCore):
+ (WebSpeechSynthesizerClientImpl):
+ * platform/mac/PlatformSpeechSynthesizerMac.mm:
+ (-[WebSpeechSynthesisWrapper speakUtterance:WebCore::]):
+ (-[WebSpeechSynthesisWrapper speechSynthesizer:didFinishSpeaking:]):
+ (WebCore::PlatformSpeechSynthesizer::PlatformSpeechSynthesizer):
+ (WebCore):
+ (WebCore::PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer):
+ (WebCore::PlatformSpeechSynthesizer::speak):
+ * platform/mock/PlatformSpeechSynthesizerMock.cpp:
+ (WebCore::PlatformSpeechSynthesizerMock::PlatformSpeechSynthesizerMock):
+ (WebCore::PlatformSpeechSynthesizerMock::speakingFinished):
+ (WebCore::PlatformSpeechSynthesizerMock::speak):
+ * platform/mock/PlatformSpeechSynthesizerMock.h:
+ (PlatformSpeechSynthesizerMock):
+
2013-03-23 Daniel Cheng <dcheng@chromium.org>
[Qt] editing/pasteboard/can-read-in-dragstart-event.html and /can-read-in-copy-and-cut-events.html are crashing
#if ENABLE(SPEECH_SYNTHESIS)
-#include "PlatformSpeechSynthesis.h"
#include "PlatformSpeechSynthesisVoice.h"
+#include "PlatformSpeechSynthesizer.h"
#include "SpeechSynthesisEvent.h"
#include "SpeechSynthesisUtterance.h"
#include <wtf/CurrentTime.h>
}
}
-void SpeechSynthesis::boundaryEventOccurred(const PlatformSpeechSynthesisUtterance* utterance, SpeechBoundary boundary, unsigned charIndex)
+void SpeechSynthesis::boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance, SpeechBoundary boundary, unsigned charIndex)
{
DEFINE_STATIC_LOCAL(const String, wordBoundaryString, (ASCIILiteral("word")));
DEFINE_STATIC_LOCAL(const String, sentenceBoundaryString, (ASCIILiteral("sentence")));
}
}
-void SpeechSynthesis::didStartSpeaking(const PlatformSpeechSynthesisUtterance* utterance)
+void SpeechSynthesis::didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
- fireEvent(eventNames().startEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
+ if (utterance->client())
+ fireEvent(eventNames().startEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
}
-void SpeechSynthesis::didPauseSpeaking(const PlatformSpeechSynthesisUtterance* utterance)
+void SpeechSynthesis::didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
m_isPaused = true;
- fireEvent(eventNames().pauseEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
+ if (utterance->client())
+ fireEvent(eventNames().pauseEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
}
-void SpeechSynthesis::didResumeSpeaking(const PlatformSpeechSynthesisUtterance* utterance)
+void SpeechSynthesis::didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
m_isPaused = false;
- fireEvent(eventNames().resumeEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
+ if (utterance->client())
+ fireEvent(eventNames().resumeEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
}
-void SpeechSynthesis::didFinishSpeaking(const PlatformSpeechSynthesisUtterance* utterance)
+void SpeechSynthesis::didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
- handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance*>(utterance->client()), false);
+ if (utterance->client())
+ handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance*>(utterance->client()), false);
}
-void SpeechSynthesis::speakingErrorOccurred(const PlatformSpeechSynthesisUtterance* utterance)
+void SpeechSynthesis::speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
- handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance*>(utterance->client()), true);
+ if (utterance->client())
+ handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance*>(utterance->client()), true);
}
-
+
} // namespace WebCore
#endif // ENABLE(INPUT_SPEECH)
// PlatformSpeechSynthesizerClient override methods.
virtual void voicesDidChange() OVERRIDE;
- virtual void didStartSpeaking(const PlatformSpeechSynthesisUtterance*) OVERRIDE;
- virtual void didPauseSpeaking(const PlatformSpeechSynthesisUtterance*) OVERRIDE;
- virtual void didResumeSpeaking(const PlatformSpeechSynthesisUtterance*) OVERRIDE;
- virtual void didFinishSpeaking(const PlatformSpeechSynthesisUtterance*) OVERRIDE;
- virtual void speakingErrorOccurred(const PlatformSpeechSynthesisUtterance*) OVERRIDE;
- virtual void boundaryEventOccurred(const PlatformSpeechSynthesisUtterance*, SpeechBoundary, unsigned charIndex) 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);
SpeechSynthesisUtterance::SpeechSynthesisUtterance(ScriptExecutionContext* context, const String& text)
: ContextDestructionObserver(context)
- , m_platformUtterance(PlatformSpeechSynthesisUtterance(this))
+ , m_platformUtterance(PlatformSpeechSynthesisUtterance::create(this))
{
- m_platformUtterance.setText(text);
+ m_platformUtterance->setText(text);
+}
+
+SpeechSynthesisUtterance::~SpeechSynthesisUtterance()
+{
+ m_platformUtterance->setClient(0);
}
ScriptExecutionContext* SpeechSynthesisUtterance::scriptExecutionContext() const
m_voice = voice;
if (voice)
- m_platformUtterance.setVoice(voice->platformVoice());
+ m_platformUtterance->setVoice(voice->platformVoice());
}
} // namespace WebCore
public:
static PassRefPtr<SpeechSynthesisUtterance> create(ScriptExecutionContext*, const String&);
- const String& text() const { return m_platformUtterance.text(); }
- void setText(const String& text) { m_platformUtterance.setText(text); }
+ ~SpeechSynthesisUtterance();
- const String& lang() const { return m_platformUtterance.lang(); }
- void setLang(const String& lang) { m_platformUtterance.setLang(lang); }
+ const String& text() const { return m_platformUtterance->text(); }
+ void setText(const String& text) { m_platformUtterance->setText(text); }
+
+ const String& lang() const { return m_platformUtterance->lang(); }
+ void setLang(const String& lang) { m_platformUtterance->setLang(lang); }
SpeechSynthesisVoice* voice() const;
void setVoice(SpeechSynthesisVoice*);
- float volume() const { return m_platformUtterance.volume(); }
- void setVolume(float volume) { m_platformUtterance.setVolume(volume); }
+ float volume() const { return m_platformUtterance->volume(); }
+ void setVolume(float volume) { m_platformUtterance->setVolume(volume); }
- float rate() const { return m_platformUtterance.rate(); }
- void setRate(float rate) { m_platformUtterance.setRate(rate); }
+ float rate() const { return m_platformUtterance->rate(); }
+ void setRate(float rate) { m_platformUtterance->setRate(rate); }
- float pitch() const { return m_platformUtterance.pitch(); }
- void setPitch(float pitch) { m_platformUtterance.setPitch(pitch); }
+ float pitch() const { return m_platformUtterance->pitch(); }
+ void setPitch(float pitch) { m_platformUtterance->setPitch(pitch); }
- double startTime() const { return m_platformUtterance.startTime(); }
- void setStartTime(double startTime) { m_platformUtterance.setStartTime(startTime); }
+ double startTime() const { return m_platformUtterance->startTime(); }
+ void setStartTime(double startTime) { m_platformUtterance->setStartTime(startTime); }
DEFINE_ATTRIBUTE_EVENT_LISTENER(start);
DEFINE_ATTRIBUTE_EVENT_LISTENER(end);
virtual ScriptExecutionContext* scriptExecutionContext() const;
- const PlatformSpeechSynthesisUtterance& platformUtterance() const { return m_platformUtterance; }
+ PlatformSpeechSynthesisUtterance* platformUtterance() const { return m_platformUtterance.get(); }
private:
SpeechSynthesisUtterance(ScriptExecutionContext*, const String&);
- PlatformSpeechSynthesisUtterance m_platformUtterance;
+ RefPtr<PlatformSpeechSynthesisUtterance> m_platformUtterance;
RefPtr<SpeechSynthesisVoice> m_voice;
// EventTarget
class SpeechSynthesisVoice : public RefCounted<SpeechSynthesisVoice> {
public:
+ virtual ~SpeechSynthesisVoice() { }
static PassRefPtr<SpeechSynthesisVoice> create(PassRefPtr<PlatformSpeechSynthesisVoice>);
const String& voiceURI() const { return m_platformVoice->voiceURI(); }
__ZTVN7WebCore25HistoryPropertyListWriterE
#if ENABLE(SPEECH_SYNTHESIS)
__ZTVN7WebCore25PlatformSpeechSynthesizerE
+__ZN7WebCore25PlatformSpeechSynthesizerD2Ev
#endif
__ZTVN7WebCore28InspectorFrontendClientLocal8SettingsE
__ZN7WebCore16CSSParserContextC1EPNS_8DocumentERKNS_4KURLERKN3WTF6StringE
'Modules/speech/SpeechSynthesisUtterance.h',
'Modules/speech/SpeechSynthesisVoice.cpp',
'Modules/speech/SpeechSynthesisVoice.h',
- 'Modules/speech/chromium/SpeechSynthesisChromium.cpp',
'Modules/webaudio/AudioBasicInspectorNode.cpp',
'Modules/webaudio/AudioBasicInspectorNode.h',
'Modules/webaudio/AudioBasicProcessorNode.cpp',
'platform/PlatformInstrumentation.h',
'platform/PlatformMemoryInstrumentation.cpp',
'platform/PlatformMemoryInstrumentation.h',
+ 'platform/PlatformSpeechSynthesisUtterance.cpp',
+ 'platform/PlatformSpeechSynthesisUtterance.h',
+ 'platform/PlatformSpeechSynthesisVoice.cpp',
+ 'platform/PlatformSpeechSynthesisVoice.h',
+ 'platform/PlatformSpeechSynthesizer.cpp',
+ 'platform/PlatformSpeechSynthesizer.h',
'platform/PlatformStrategies.cpp',
'platform/PlatformTouchEvent.h',
'platform/PlatformTouchPoint.h',
'platform/chromium/PlatformScreenChromium.cpp',
'platform/chromium/PlatformThemeChromiumDefault.cpp',
'platform/chromium/PlatformThemeChromiumDefault.h',
+ 'platform/chromium/PlatformSpeechSynthesizerChromium.cpp',
'platform/chromium/PlatformWidget.h',
'platform/chromium/PopupContainer.cpp',
'platform/chromium/PopupContainer.h',
'webcore_test_support_files': [
'inspector/InspectorFrontendClientLocal.cpp',
'inspector/InspectorFrontendClientLocal.h',
- 'platform/mock/PlatformSpeechSynthesizerMock.cpp',
- 'platform/mock/PlatformSpeechSynthesizerMock.h',
'testing/v8/WebCoreTestSupport.cpp',
'testing/v8/WebCoreTestSupport.h',
'testing/js/WebCoreTestSupport.cpp',
'platform/chromium/support/WebScrollbarThemeGeometryNative.h',
'platform/chromium/support/WebScrollbarImpl.cpp',
'platform/chromium/support/WebScrollbarImpl.h',
+ 'platform/chromium/support/WebSpeechSynthesisUtterance.cpp',
+ 'platform/chromium/support/WebSpeechSynthesisVoice.cpp',
+ 'platform/chromium/support/WebSpeechSynthesizerClientImpl.cpp',
+ 'platform/chromium/support/WebSpeechSynthesizerClientImpl.h',
'platform/chromium/support/WebThreadSafeData.cpp',
'platform/chromium/support/WebTransformKeyframe.cpp',
'platform/chromium/support/WebURL.cpp',
#if ENABLE(SPEECH_SYNTHESIS)
+#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
namespace WebCore {
private:
PlatformSpeechSynthesis(SpeechSynthesis*);
- SpeechSynthesis* m_speechSynthsis;
+ SpeechSynthesis* m_speechSynthesis;
};
} // namespace WebCore
#if ENABLE(SPEECH_SYNTHESIS)
namespace WebCore {
+
+PassRefPtr<PlatformSpeechSynthesisUtterance> PlatformSpeechSynthesisUtterance::create(PlatformSpeechSynthesisUtteranceClient* client)
+{
+ return adoptRef(new PlatformSpeechSynthesisUtterance(client));
+}
PlatformSpeechSynthesisUtterance::PlatformSpeechSynthesisUtterance(PlatformSpeechSynthesisUtteranceClient* client)
: m_client(client)
#if ENABLE(SPEECH_SYNTHESIS)
#include "PlatformSpeechSynthesisVoice.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
virtual ~PlatformSpeechSynthesisUtteranceClient() { }
};
-class PlatformSpeechSynthesisUtterance {
+class PlatformSpeechSynthesisUtterance : public RefCounted<PlatformSpeechSynthesisUtterance> {
public:
- explicit PlatformSpeechSynthesisUtterance(PlatformSpeechSynthesisUtteranceClient*);
+ static PassRefPtr<PlatformSpeechSynthesisUtterance> create(PlatformSpeechSynthesisUtteranceClient*);
const String& text() const { return m_text; }
void setText(const String& text) { m_text = text; }
void setStartTime(double startTime) { m_startTime = startTime; }
PlatformSpeechSynthesisUtteranceClient* client() const { return m_client; }
+ void setClient(PlatformSpeechSynthesisUtteranceClient* client) { m_client = client; }
private:
+ explicit PlatformSpeechSynthesisUtterance(PlatformSpeechSynthesisUtteranceClient*);
+
PlatformSpeechSynthesisUtteranceClient* m_client;
String m_text;
String m_lang;
{
return adoptRef(new PlatformSpeechSynthesisVoice(voiceURI, name, lang, localService, isDefault));
}
+
+PassRefPtr<PlatformSpeechSynthesisVoice> PlatformSpeechSynthesisVoice::create()
+{
+ return adoptRef(new PlatformSpeechSynthesisVoice());
+}
PlatformSpeechSynthesisVoice::PlatformSpeechSynthesisVoice(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault)
: m_voiceURI(voiceURI)
{
}
+PlatformSpeechSynthesisVoice::PlatformSpeechSynthesisVoice()
+ : m_localService(false)
+ , m_default(false)
+{
+}
+
} // namespace WebCore
#endif // ENABLE(SPEECH_SYNTHESIS)
class PlatformSpeechSynthesisVoice : public RefCounted<PlatformSpeechSynthesisVoice> {
public:
static PassRefPtr<PlatformSpeechSynthesisVoice> create(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault);
-
+ static PassRefPtr<PlatformSpeechSynthesisVoice> create();
+
const String& voiceURI() const { return m_voiceURI; }
+ void setVoiceURI(const String& voiceURI) { m_voiceURI = voiceURI; }
+
const String& name() const { return m_name; }
+ void setName(const String& name) { m_name = name; }
+
const String& lang() const { return m_lang; }
+ void setLang(const String& lang) { m_lang = lang; }
+
bool localService() const { return m_localService; }
+ void setLocalService(bool localService) { m_localService = localService; }
+
bool isDefault() const { return m_default; }
-
+ void setIsDefault(bool isDefault) { m_default = isDefault; }
+
private:
PlatformSpeechSynthesisVoice(const String& voiceURI, const String& name, const String& lang, bool localService, bool isDefault);
+ PlatformSpeechSynthesisVoice();
String m_voiceURI;
String m_name;
PassOwnPtr<PlatformSpeechSynthesizer> PlatformSpeechSynthesizer::create(PlatformSpeechSynthesizerClient* client)
{
- return adoptPtr(new PlatformSpeechSynthesizer(client));
+ OwnPtr<PlatformSpeechSynthesizer> synthesizer = adoptPtr(new PlatformSpeechSynthesizer(client));
+ synthesizer->initializeVoiceList();
+ return synthesizer.release();
}
-PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient* client)
- : m_speechSynthesizerClient(client)
+void PlatformSpeechSynthesizer::setVoiceList(Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voices)
{
- initializeVoiceList();
+ m_voiceList = voices;
}
-
+
+
} // namespace WebCore
#endif // ENABLE(SPEECH_SYNTHESIS)
OBJC_CLASS WebSpeechSynthesisWrapper;
#endif
+#if PLATFORM(CHROMIUM)
+namespace WebKit {
+class WebSpeechSynthesizer;
+class WebSpeechSynthesizerClient;
+}
+#endif
+
namespace WebCore {
enum SpeechBoundary {
class PlatformSpeechSynthesizerClient {
public:
- virtual void didStartSpeaking(const PlatformSpeechSynthesisUtterance*) = 0;
- virtual void didFinishSpeaking(const PlatformSpeechSynthesisUtterance*) = 0;
- virtual void didPauseSpeaking(const PlatformSpeechSynthesisUtterance*) = 0;
- virtual void didResumeSpeaking(const PlatformSpeechSynthesisUtterance*) = 0;
- virtual void speakingErrorOccurred(const PlatformSpeechSynthesisUtterance*) = 0;
- virtual void boundaryEventOccurred(const PlatformSpeechSynthesisUtterance*, SpeechBoundary, unsigned charIndex) = 0;
+ virtual void didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
+ virtual void didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
+ virtual void didPauseSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
+ virtual void didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
+ virtual void speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>) = 0;
+ virtual void boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance>, SpeechBoundary, unsigned charIndex) = 0;
virtual void voicesDidChange() = 0;
protected:
virtual ~PlatformSpeechSynthesizerClient() { }
public:
static PassOwnPtr<PlatformSpeechSynthesizer> create(PlatformSpeechSynthesizerClient*);
- virtual ~PlatformSpeechSynthesizer() { }
+ virtual ~PlatformSpeechSynthesizer();
const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voiceList() const { return m_voiceList; }
- virtual void speak(const PlatformSpeechSynthesisUtterance&);
+ virtual void speak(PassRefPtr<PlatformSpeechSynthesisUtterance>);
virtual void pause();
virtual void resume();
virtual void cancel();
PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizerClient; }
-
+
+ void setVoiceList(Vector<RefPtr<PlatformSpeechSynthesisVoice> >&);
+
protected:
+ virtual void initializeVoiceList();
explicit PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient*);
Vector<RefPtr<PlatformSpeechSynthesisVoice> > m_voiceList;
private:
PlatformSpeechSynthesizerClient* m_speechSynthesizerClient;
- virtual void initializeVoiceList();
#if PLATFORM(MAC)
RetainPtr<WebSpeechSynthesisWrapper> m_platformSpeechWrapper;
#endif
+#if PLATFORM(CHROMIUM)
+ OwnPtr<WebKit::WebSpeechSynthesizer> m_webSpeechSynthesizer;
+ OwnPtr<WebKit::WebSpeechSynthesizerClient> m_webSpeechSynthesizerClient;
+#endif
};
} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (c) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformSpeechSynthesizer.h"
+
+#include "PlatformSpeechSynthesisUtterance.h"
+#include "PlatformSpeechSynthesisVoice.h"
+#include "WebSpeechSynthesizerClientImpl.h"
+#include <public/Platform.h>
+#include <public/WebSpeechSynthesisUtterance.h>
+#include <public/WebSpeechSynthesizer.h>
+#include <public/WebSpeechSynthesizerClient.h>
+#include <wtf/RetainPtr.h>
+
+#if ENABLE(SPEECH_SYNTHESIS)
+
+namespace WebCore {
+
+PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient* client)
+ : m_speechSynthesizerClient(client)
+{
+ m_webSpeechSynthesizerClient = adoptPtr(new WebSpeechSynthesizerClientImpl(this, client));
+ m_webSpeechSynthesizer = adoptPtr(WebKit::Platform::current()->createSpeechSynthesizer(m_webSpeechSynthesizerClient.get()));
+}
+
+PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer()
+{
+}
+
+void PlatformSpeechSynthesizer::initializeVoiceList()
+{
+ if (m_webSpeechSynthesizer.get())
+ m_webSpeechSynthesizer->updateVoiceList();
+}
+
+void PlatformSpeechSynthesizer::speak(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
+{
+ if (!m_webSpeechSynthesizer || !m_webSpeechSynthesizerClient)
+ return;
+
+ m_webSpeechSynthesizer->speak(WebKit::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();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SPEECH_SYNTHESIS)
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SPEECH_SYNTHESIS)
+
+#include <public/WebSpeechSynthesisUtterance.h>
+
+#include "PlatformSpeechSynthesisUtterance.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebSpeechSynthesisUtterance::WebSpeechSynthesisUtterance(const PassRefPtr<PlatformSpeechSynthesisUtterance>& utterance)
+ : m_private(utterance)
+{
+}
+
+WebSpeechSynthesisUtterance& WebSpeechSynthesisUtterance::operator=(WebCore::PlatformSpeechSynthesisUtterance* utterance)
+{
+ m_private = utterance;
+ return *this;
+}
+
+void WebSpeechSynthesisUtterance::assign(const WebSpeechSynthesisUtterance& other)
+{
+ m_private = other.m_private;
+}
+
+void WebSpeechSynthesisUtterance::reset()
+{
+ m_private.reset();
+}
+
+WebSpeechSynthesisUtterance::operator PassRefPtr<PlatformSpeechSynthesisUtterance>() const
+{
+ return m_private.get();
+}
+
+WebSpeechSynthesisUtterance::operator PlatformSpeechSynthesisUtterance*() const
+{
+ return m_private.get();
+}
+
+WebString WebSpeechSynthesisUtterance::text() const
+{
+ return m_private->text();
+}
+
+WebString WebSpeechSynthesisUtterance::lang() const
+{
+ return m_private->lang();
+}
+
+WebString WebSpeechSynthesisUtterance::voice() const
+{
+ return m_private->voice() ? WebString(m_private->voice()->name()) : WebString();
+}
+
+float WebSpeechSynthesisUtterance::volume() const
+{
+ return m_private->volume();
+}
+
+float WebSpeechSynthesisUtterance::rate() const
+{
+ return m_private->rate();
+}
+
+float WebSpeechSynthesisUtterance::pitch() const
+{
+ return m_private->pitch();
+}
+
+double WebSpeechSynthesisUtterance::startTime() const
+{
+ return m_private->startTime();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(SPEECH_SYNTHESIS)
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <public/WebSpeechSynthesisVoice.h>
+
+#include "SpeechRecognitionAlternative.h"
+#include "SpeechSynthesisVoice.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/Vector.h>
+
+#if ENABLE(SPEECH_SYNTHESIS)
+
+namespace WebKit {
+
+void WebSpeechSynthesisVoice::assign(const WebSpeechSynthesisVoice& other)
+{
+ m_private = other.m_private;
+}
+
+void WebSpeechSynthesisVoice::reset()
+{
+ m_private.reset();
+}
+
+void WebSpeechSynthesisVoice::setVoiceURI(const WebString& voiceURI)
+{
+ m_private->setVoiceURI(voiceURI);
+}
+
+void WebSpeechSynthesisVoice::setName(const WebString& name)
+{
+ m_private->setName(name);
+}
+
+void WebSpeechSynthesisVoice::setLanguage(const WebString& language)
+{
+ m_private->setLang(language);
+}
+
+void WebSpeechSynthesisVoice::setIsLocalService(bool isLocalService)
+{
+ m_private->setLocalService(isLocalService);
+}
+
+void WebSpeechSynthesisVoice::setIsDefault(bool isDefault)
+{
+ m_private->setIsDefault(isDefault);
+}
+
+WebSpeechSynthesisVoice::operator PassRefPtr<WebCore::PlatformSpeechSynthesisVoice>() const
+{
+ return m_private.get();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(SPEECH_SYNTHESIS)
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSpeechSynthesizerClientImpl.h"
+
+#include "PlatformSpeechSynthesisUtterance.h"
+
+namespace WebCore {
+
+WebSpeechSynthesizerClientImpl::WebSpeechSynthesizerClientImpl(PlatformSpeechSynthesizer* synthesizer, PlatformSpeechSynthesizerClient* client)
+#if ENABLE(SPEECH_SYNTHESIS)
+ : m_synthesizer(synthesizer)
+ , m_client(client)
+#endif
+{
+}
+
+WebSpeechSynthesizerClientImpl::~WebSpeechSynthesizerClientImpl()
+{
+}
+
+void WebSpeechSynthesizerClientImpl::setVoiceList(const WebKit::WebVector<WebKit::WebSpeechSynthesisVoice>& voices)
+{
+#if ENABLE(SPEECH_SYNTHESIS)
+ Vector<RefPtr<PlatformSpeechSynthesisVoice> > outVoices;
+ for (size_t i = 0; i < voices.size(); i++)
+ outVoices.append(PassRefPtr<PlatformSpeechSynthesisVoice>(voices[i]));
+ m_synthesizer->setVoiceList(outVoices);
+ m_client->voicesDidChange();
+#endif
+}
+
+void WebSpeechSynthesizerClientImpl::didStartSpeaking(const WebKit::WebSpeechSynthesisUtterance& utterance)
+{
+#if ENABLE(SPEECH_SYNTHESIS)
+ m_client->didStartSpeaking(utterance);
+#endif
+}
+
+void WebSpeechSynthesizerClientImpl::didFinishSpeaking(const WebKit::WebSpeechSynthesisUtterance& utterance)
+{
+#if ENABLE(SPEECH_SYNTHESIS)
+ m_client->didFinishSpeaking(utterance);
+#endif
+}
+
+void WebSpeechSynthesizerClientImpl::didPauseSpeaking(const WebKit::WebSpeechSynthesisUtterance& utterance)
+{
+#if ENABLE(SPEECH_SYNTHESIS)
+ m_client->didPauseSpeaking(utterance);
+#endif
+}
+
+void WebSpeechSynthesizerClientImpl::didResumeSpeaking(const WebKit::WebSpeechSynthesisUtterance& utterance)
+{
+#if ENABLE(SPEECH_SYNTHESIS)
+ m_client->didResumeSpeaking(utterance);
+#endif
+}
+
+void WebSpeechSynthesizerClientImpl::speakingErrorOccurred(const WebKit::WebSpeechSynthesisUtterance& utterance)
+{
+#if ENABLE(SPEECH_SYNTHESIS)
+ m_client->speakingErrorOccurred(utterance);
+#endif
+}
+
+void WebSpeechSynthesizerClientImpl::wordBoundaryEventOccurred(const WebKit::WebSpeechSynthesisUtterance& utterance, unsigned charIndex)
+{
+#if ENABLE(SPEECH_SYNTHESIS)
+ m_client->boundaryEventOccurred(utterance, SpeechWordBoundary, charIndex);
+#endif
+}
+
+void WebSpeechSynthesizerClientImpl::sentenceBoundaryEventOccurred(const WebKit::WebSpeechSynthesisUtterance& utterance, unsigned charIndex)
+{
+#if ENABLE(SPEECH_SYNTHESIS)
+ m_client->boundaryEventOccurred(utterance, SpeechSentenceBoundary, charIndex);
+#endif
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSpeechSynthesizerClientImpl_h
+#define WebSpeechSynthesizerClientImpl_h
+
+#include "PlatformSpeechSynthesizer.h"
+#include <public/WebSpeechSynthesisUtterance.h>
+#include <public/WebSpeechSynthesisVoice.h>
+#include <public/WebSpeechSynthesizerClient.h>
+#include <wtf/HashMap.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class PlatformSpeechSynthesizer;
+class PlatformSpeechSynthesizerClient;
+
+class WebSpeechSynthesizerClientImpl : public WebKit::WebSpeechSynthesizerClient {
+public:
+ explicit WebSpeechSynthesizerClientImpl(PlatformSpeechSynthesizer*, PlatformSpeechSynthesizerClient*);
+ virtual ~WebSpeechSynthesizerClientImpl();
+
+ virtual void setVoiceList(const WebKit::WebVector<WebKit::WebSpeechSynthesisVoice>& voices);
+ virtual void didStartSpeaking(const WebKit::WebSpeechSynthesisUtterance&);
+ virtual void didFinishSpeaking(const WebKit::WebSpeechSynthesisUtterance&);
+ virtual void didPauseSpeaking(const WebKit::WebSpeechSynthesisUtterance&);
+ virtual void didResumeSpeaking(const WebKit::WebSpeechSynthesisUtterance&);
+ virtual void speakingErrorOccurred(const WebKit::WebSpeechSynthesisUtterance&);
+ virtual void wordBoundaryEventOccurred(const WebKit::WebSpeechSynthesisUtterance&, unsigned charIndex);
+ virtual void sentenceBoundaryEventOccurred(const WebKit::WebSpeechSynthesisUtterance&, unsigned charIndex);
+
+private:
+#if ENABLE(SPEECH_SYNTHESIS)
+ PlatformSpeechSynthesizer* m_synthesizer;
+ PlatformSpeechSynthesizerClient* m_client;
+#endif
+};
+
+} // namespace WebCore
+
+#endif // WebSpeechSynthesizerClientImpl_h
#include "PlatformSpeechSynthesisUtterance.h"
#include "PlatformSpeechSynthesisVoice.h"
#include <AppKit/NSSpeechSynthesizer.h>
+#include <wtf/PassRefPtr.h>
#include <wtf/RetainPtr.h>
#if ENABLE(SPEECH_SYNTHESIS)
{
WebCore::PlatformSpeechSynthesizer* m_synthesizerObject;
// Hold a Ref to the utterance so that it won't disappear until the synth is done with it.
- const WebCore::PlatformSpeechSynthesisUtterance* m_utterance;
+ WebCore::PlatformSpeechSynthesisUtterance* m_utterance;
RetainPtr<NSSpeechSynthesizer> m_synthesizer;
float m_basePitch;
}
- (WebSpeechSynthesisWrapper *)initWithSpeechSynthesizer:(WebCore::PlatformSpeechSynthesizer *)synthesizer;
-- (void)speakUtterance:(const WebCore::PlatformSpeechSynthesisUtterance *)utterance;
+- (void)speakUtterance:(WebCore::PlatformSpeechSynthesisUtterance *)utterance;
@end
m_basePitch = [[m_synthesizer objectForProperty:NSSpeechPitchBaseProperty error:nil] floatValue];
}
-- (void)speakUtterance:(const WebCore::PlatformSpeechSynthesisUtterance *)utterance
+- (void)speakUtterance:(WebCore::PlatformSpeechSynthesisUtterance *)utterance
{
// When speak is called we should not have an existing speech utterance outstanding.
ASSERT(!m_utterance);
UNUSED_PARAM(sender);
// Clear the m_utterance variable in case finish speaking kicks off a new speaking job immediately.
- const WebCore::PlatformSpeechSynthesisUtterance* utterance = m_utterance;
+ WebCore::PlatformSpeechSynthesisUtterance* utterance = m_utterance;
m_utterance = 0;
if (finishedSpeaking)
namespace WebCore {
+PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient* client)
+ : m_speechSynthesizerClient(client)
+{
+}
+
+PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer()
+{
+}
+
void PlatformSpeechSynthesizer::initializeVoiceList()
{
NSString *defaultVoiceURI = [NSSpeechSynthesizer defaultVoice];
[m_platformSpeechWrapper.get() resume];
}
-void PlatformSpeechSynthesizer::speak(const PlatformSpeechSynthesisUtterance& utterance)
+void PlatformSpeechSynthesizer::speak(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
if (!m_platformSpeechWrapper)
m_platformSpeechWrapper.adoptNS([[WebSpeechSynthesisWrapper alloc] initWithSpeechSynthesizer:this]);
- [m_platformSpeechWrapper.get() speakUtterance:&utterance];
+ [m_platformSpeechWrapper.get() speakUtterance:utterance.get()];
}
void PlatformSpeechSynthesizer::cancel()
PassOwnPtr<PlatformSpeechSynthesizerMock> PlatformSpeechSynthesizerMock::create(PlatformSpeechSynthesizerClient* client)
{
- return adoptPtr(new PlatformSpeechSynthesizerMock(client));
+ OwnPtr<PlatformSpeechSynthesizerMock> synthesizer = adoptPtr(new PlatformSpeechSynthesizerMock(client));
+ synthesizer->initializeVoiceList();
+ return synthesizer.release();
}
PlatformSpeechSynthesizerMock::PlatformSpeechSynthesizerMock(PlatformSpeechSynthesizerClient* client)
: PlatformSpeechSynthesizer(client)
, m_speakingFinishedTimer(this, &PlatformSpeechSynthesizerMock::speakingFinished)
- , m_utterance(0)
{
}
void PlatformSpeechSynthesizerMock::speakingFinished(Timer<PlatformSpeechSynthesizerMock>*)
{
- ASSERT(m_utterance);
+ ASSERT(m_utterance.get());
client()->didFinishSpeaking(m_utterance);
m_utterance = 0;
}
m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.logan"), String("logan"), String("fr-CA"), true, true));
}
-void PlatformSpeechSynthesizerMock::speak(const PlatformSpeechSynthesisUtterance& utterance)
+void PlatformSpeechSynthesizerMock::speak(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
ASSERT(!m_utterance);
- m_utterance = &utterance;
+ m_utterance = utterance;
client()->didStartSpeaking(m_utterance);
// Fire a fake word and then sentence boundary event.
static PassOwnPtr<PlatformSpeechSynthesizerMock> create(PlatformSpeechSynthesizerClient*);
virtual ~PlatformSpeechSynthesizerMock();
- virtual void speak(const PlatformSpeechSynthesisUtterance&);
+ virtual void speak(PassRefPtr<PlatformSpeechSynthesisUtterance>);
virtual void pause();
virtual void resume();
virtual void cancel();
void speakingFinished(Timer<PlatformSpeechSynthesizerMock>*);
Timer<PlatformSpeechSynthesizerMock> m_speakingFinishedTimer;
- const PlatformSpeechSynthesisUtterance* m_utterance;
+ RefPtr<PlatformSpeechSynthesisUtterance> m_utterance;
};
} // namespace WebCore