From 99c2e698d2a3c56649e42d8d2133706cd8c9501e Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 20 May 2020 10:19:04 +0000 Subject: Issue #1538 - remove speech recognition engine This removes speech recognition, pocketsphinx, training models and the speech automated test interface. This also re-establishes proper use of MOZ_WEBSPEECH to work for the speech API (synthesis part only) that was a broken mess before, with some synth parts being always built, some parts being built only with it enabled and recognition parts being dependent on it. I'm pretty sure it'd be totally busted if you'd ever have tried building without MOZ_WEBPEECH before. Tested that synthesis still works as-intended. This resolves #1538 --- dom/media/webspeech/synth/moz.build | 74 ++-- dom/media/webspeech/synth/test/FakeSynthModule.cpp | 55 --- dom/media/webspeech/synth/test/common.js | 91 ----- .../webspeech/synth/test/file_bfcache_frame.html | 28 -- .../webspeech/synth/test/file_global_queue.html | 69 ---- .../synth/test/file_global_queue_cancel.html | 88 ----- .../synth/test/file_global_queue_pause.html | 131 ------- .../synth/test/file_indirect_service_events.html | 102 ------ dom/media/webspeech/synth/test/file_setup.html | 95 ----- .../webspeech/synth/test/file_speech_cancel.html | 100 ----- .../webspeech/synth/test/file_speech_error.html | 46 --- .../webspeech/synth/test/file_speech_queue.html | 85 ----- .../webspeech/synth/test/file_speech_simple.html | 53 --- dom/media/webspeech/synth/test/mochitest.ini | 26 -- .../webspeech/synth/test/nsFakeSynthServices.cpp | 401 --------------------- .../webspeech/synth/test/nsFakeSynthServices.h | 52 --- .../synth/test/startup/file_voiceschanged.html | 32 -- .../webspeech/synth/test/startup/mochitest.ini | 7 - .../synth/test/startup/test_voiceschanged.html | 32 -- dom/media/webspeech/synth/test/test_bfcache.html | 45 --- .../webspeech/synth/test/test_global_queue.html | 35 -- .../synth/test/test_global_queue_cancel.html | 35 -- .../synth/test/test_global_queue_pause.html | 35 -- .../synth/test/test_indirect_service_events.html | 36 -- dom/media/webspeech/synth/test/test_setup.html | 32 -- .../webspeech/synth/test/test_speech_cancel.html | 35 -- .../webspeech/synth/test/test_speech_error.html | 35 -- .../webspeech/synth/test/test_speech_queue.html | 37 -- .../webspeech/synth/test/test_speech_simple.html | 34 -- 29 files changed, 31 insertions(+), 1895 deletions(-) delete mode 100644 dom/media/webspeech/synth/test/FakeSynthModule.cpp delete mode 100644 dom/media/webspeech/synth/test/common.js delete mode 100644 dom/media/webspeech/synth/test/file_bfcache_frame.html delete mode 100644 dom/media/webspeech/synth/test/file_global_queue.html delete mode 100644 dom/media/webspeech/synth/test/file_global_queue_cancel.html delete mode 100644 dom/media/webspeech/synth/test/file_global_queue_pause.html delete mode 100644 dom/media/webspeech/synth/test/file_indirect_service_events.html delete mode 100644 dom/media/webspeech/synth/test/file_setup.html delete mode 100644 dom/media/webspeech/synth/test/file_speech_cancel.html delete mode 100644 dom/media/webspeech/synth/test/file_speech_error.html delete mode 100644 dom/media/webspeech/synth/test/file_speech_queue.html delete mode 100644 dom/media/webspeech/synth/test/file_speech_simple.html delete mode 100644 dom/media/webspeech/synth/test/mochitest.ini delete mode 100644 dom/media/webspeech/synth/test/nsFakeSynthServices.cpp delete mode 100644 dom/media/webspeech/synth/test/nsFakeSynthServices.h delete mode 100644 dom/media/webspeech/synth/test/startup/file_voiceschanged.html delete mode 100644 dom/media/webspeech/synth/test/startup/mochitest.ini delete mode 100644 dom/media/webspeech/synth/test/startup/test_voiceschanged.html delete mode 100644 dom/media/webspeech/synth/test/test_bfcache.html delete mode 100644 dom/media/webspeech/synth/test/test_global_queue.html delete mode 100644 dom/media/webspeech/synth/test/test_global_queue_cancel.html delete mode 100644 dom/media/webspeech/synth/test/test_global_queue_pause.html delete mode 100644 dom/media/webspeech/synth/test/test_indirect_service_events.html delete mode 100644 dom/media/webspeech/synth/test/test_setup.html delete mode 100644 dom/media/webspeech/synth/test/test_speech_cancel.html delete mode 100644 dom/media/webspeech/synth/test/test_speech_error.html delete mode 100644 dom/media/webspeech/synth/test/test_speech_queue.html delete mode 100644 dom/media/webspeech/synth/test/test_speech_simple.html (limited to 'dom/media/webspeech/synth') diff --git a/dom/media/webspeech/synth/moz.build b/dom/media/webspeech/synth/moz.build index 7b8c4cd31..3f4e363db 100644 --- a/dom/media/webspeech/synth/moz.build +++ b/dom/media/webspeech/synth/moz.build @@ -3,56 +3,44 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -if CONFIG['MOZ_WEBSPEECH']: - MOCHITEST_MANIFESTS += [ - 'test/mochitest.ini', - 'test/startup/mochitest.ini', - ] +XPIDL_MODULE = 'dom_webspeechsynth' - XPIDL_MODULE = 'dom_webspeechsynth' - - XPIDL_SOURCES += [ - 'nsISpeechService.idl', - 'nsISynthVoiceRegistry.idl' - ] - - EXPORTS.mozilla.dom += [ - 'ipc/SpeechSynthesisChild.h', - 'ipc/SpeechSynthesisParent.h', - 'nsSpeechTask.h', - 'nsSynthVoiceRegistry.h', - 'SpeechSynthesis.h', - 'SpeechSynthesisUtterance.h', - 'SpeechSynthesisVoice.h', - ] +XPIDL_SOURCES += [ + 'nsISpeechService.idl', + 'nsISynthVoiceRegistry.idl' +] - SOURCES += [ - 'ipc/SpeechSynthesisChild.cpp', - 'ipc/SpeechSynthesisParent.cpp', - 'nsSpeechTask.cpp', - 'nsSynthVoiceRegistry.cpp', - 'SpeechSynthesis.cpp', - 'SpeechSynthesisUtterance.cpp', - 'SpeechSynthesisVoice.cpp', - ] +EXPORTS.mozilla.dom += [ + 'ipc/SpeechSynthesisChild.h', + 'ipc/SpeechSynthesisParent.h', + 'nsSpeechTask.h', + 'nsSynthVoiceRegistry.h', + 'SpeechSynthesis.h', + 'SpeechSynthesisUtterance.h', + 'SpeechSynthesisVoice.h', +] - if CONFIG['MOZ_WEBSPEECH_TEST_BACKEND']: - SOURCES += [ - 'test/FakeSynthModule.cpp', - 'test/nsFakeSynthServices.cpp' - ] +SOURCES += [ + 'ipc/SpeechSynthesisChild.cpp', + 'ipc/SpeechSynthesisParent.cpp', + 'nsSpeechTask.cpp', + 'nsSynthVoiceRegistry.cpp', + 'SpeechSynthesis.cpp', + 'SpeechSynthesisUtterance.cpp', + 'SpeechSynthesisVoice.cpp', +] - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': - DIRS += ['windows'] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + DIRS += ['windows'] - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': - DIRS += ['cocoa'] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': + DIRS += ['cocoa'] - if CONFIG['MOZ_SYNTH_SPEECHD']: - DIRS += ['speechd'] +if CONFIG['MOZ_SYNTH_SPEECHD']: + DIRS += ['speechd'] - if CONFIG['MOZ_SYNTH_PICO']: - DIRS += ['pico'] +if CONFIG['MOZ_SYNTH_PICO']: + DIRS += ['pico'] IPDL_SOURCES += [ 'ipc/PSpeechSynthesis.ipdl', diff --git a/dom/media/webspeech/synth/test/FakeSynthModule.cpp b/dom/media/webspeech/synth/test/FakeSynthModule.cpp deleted file mode 100644 index 5621ab78a..000000000 --- a/dom/media/webspeech/synth/test/FakeSynthModule.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ModuleUtils.h" -#include "nsIClassInfoImpl.h" - -#include "nsFakeSynthServices.h" - -using namespace mozilla::dom; - -#define FAKESYNTHSERVICE_CID \ - {0xe7d52d9e, 0xc148, 0x47d8, {0xab, 0x2a, 0x95, 0xd7, 0xf4, 0x0e, 0xa5, 0x3d}} - -#define FAKESYNTHSERVICE_CONTRACTID "@mozilla.org/fakesynth;1" - -// Defines nsFakeSynthServicesConstructor -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsFakeSynthServices, - nsFakeSynthServices::GetInstanceForService) - -// Defines kFAKESYNTHSERVICE_CID -NS_DEFINE_NAMED_CID(FAKESYNTHSERVICE_CID); - -static const mozilla::Module::CIDEntry kCIDs[] = { - { &kFAKESYNTHSERVICE_CID, true, nullptr, nsFakeSynthServicesConstructor }, - { nullptr } -}; - -static const mozilla::Module::ContractIDEntry kContracts[] = { - { FAKESYNTHSERVICE_CONTRACTID, &kFAKESYNTHSERVICE_CID }, - { nullptr } -}; - -static const mozilla::Module::CategoryEntry kCategories[] = { - { "speech-synth-started", "Fake Speech Synth", FAKESYNTHSERVICE_CONTRACTID }, - { nullptr } -}; - -static void -UnloadFakeSynthmodule() -{ - nsFakeSynthServices::Shutdown(); -} - -static const mozilla::Module kModule = { - mozilla::Module::kVersion, - kCIDs, - kContracts, - kCategories, - nullptr, - nullptr, - UnloadFakeSynthmodule -}; - -NSMODULE_DEFN(fakesynth) = &kModule; diff --git a/dom/media/webspeech/synth/test/common.js b/dom/media/webspeech/synth/test/common.js deleted file mode 100644 index 0ce9ec51b..000000000 --- a/dom/media/webspeech/synth/test/common.js +++ /dev/null @@ -1,91 +0,0 @@ -function synthTestQueue(aTestArgs, aEndFunc) { - var utterances = []; - for (var i in aTestArgs) { - var uargs = aTestArgs[i][0]; - var win = uargs.win || window; - var u = new win.SpeechSynthesisUtterance(uargs.text); - - if (uargs.args) { - for (var attr in uargs.args) - u[attr] = uargs.args[attr]; - } - - function onend_handler(e) { - is(e.target, utterances.shift(), "Target matches utterances"); - ok(!speechSynthesis.speaking, "speechSynthesis is not speaking."); - - if (utterances.length) { - ok(speechSynthesis.pending, "other utterances queued"); - } else { - ok(!speechSynthesis.pending, "queue is empty, nothing pending."); - if (aEndFunc) - aEndFunc(); - } - } - - u.addEventListener('start', - (function (expectedUri) { - return function (e) { - if (expectedUri) { - var chosenVoice = SpecialPowers.wrap(e).target.chosenVoiceURI; - is(chosenVoice, expectedUri, "Incorrect URI is used"); - } - }; - })(aTestArgs[i][1] ? aTestArgs[i][1].uri : null)); - - u.addEventListener('end', onend_handler); - u.addEventListener('error', onend_handler); - - u.addEventListener('error', - (function (expectedError) { - return function onerror_handler(e) { - ok(expectedError, "Error in speech utterance '" + e.target.text + "'"); - }; - })(aTestArgs[i][1] ? aTestArgs[i][1].err : false)); - - utterances.push(u); - win.speechSynthesis.speak(u); - } - - ok(!speechSynthesis.speaking, "speechSynthesis is not speaking yet."); - ok(speechSynthesis.pending, "speechSynthesis has an utterance queued."); -} - -function loadFrame(frameId) { - return new Promise(function(resolve, reject) { - var frame = document.getElementById(frameId); - frame.addEventListener('load', function (e) { - frame.contentWindow.document.title = frameId; - resolve(frame); - }); - frame.src = 'data:text/html,' + encodeURI(''); - }); -} - -function waitForVoices(win) { - return new Promise(resolve => { - function resolver() { - if (win.speechSynthesis.getVoices().length) { - win.speechSynthesis.removeEventListener('voiceschanged', resolver); - resolve(); - } - } - - win.speechSynthesis.addEventListener('voiceschanged', resolver); - resolver(); - }); -} - -function loadSpeechTest(fileName, prefs, frameId="testFrame") { - loadFrame(frameId).then(frame => { - waitForVoices(frame.contentWindow).then( - () => document.getElementById("testFrame").src = fileName); - }); -} - -function testSynthState(win, expectedState) { - for (var attr in expectedState) { - is(win.speechSynthesis[attr], expectedState[attr], - win.document.title + ": '" + attr + '" does not match'); - } -} \ No newline at end of file diff --git a/dom/media/webspeech/synth/test/file_bfcache_frame.html b/dom/media/webspeech/synth/test/file_bfcache_frame.html deleted file mode 100644 index c8663b7fb..000000000 --- a/dom/media/webspeech/synth/test/file_bfcache_frame.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - diff --git a/dom/media/webspeech/synth/test/file_global_queue.html b/dom/media/webspeech/synth/test/file_global_queue.html deleted file mode 100644 index 5d762c0d5..000000000 --- a/dom/media/webspeech/synth/test/file_global_queue.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - Test for Bug 1188099: Global queue should correctly schedule utterances - - - - -Mozilla Bug 1188099 - - - -
-
-
- - diff --git a/dom/media/webspeech/synth/test/file_global_queue_cancel.html b/dom/media/webspeech/synth/test/file_global_queue_cancel.html deleted file mode 100644 index 03b77ba2f..000000000 --- a/dom/media/webspeech/synth/test/file_global_queue_cancel.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - Test for Bug 1188099: Calling cancel() should work correctly with global queue - - - - -Mozilla Bug 1188099 - - - -
-
-
- - diff --git a/dom/media/webspeech/synth/test/file_global_queue_pause.html b/dom/media/webspeech/synth/test/file_global_queue_pause.html deleted file mode 100644 index 7fd562133..000000000 --- a/dom/media/webspeech/synth/test/file_global_queue_pause.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - Test for Bug 1188099: Calling pause() should work correctly with global queue - - - - -Mozilla Bug 1188099 - - - -
-
-
- - diff --git a/dom/media/webspeech/synth/test/file_indirect_service_events.html b/dom/media/webspeech/synth/test/file_indirect_service_events.html deleted file mode 100644 index fb4e31244..000000000 --- a/dom/media/webspeech/synth/test/file_indirect_service_events.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - Test for Bug 1155034: Check that indirect audio services dispatch their own events - - - - -Mozilla Bug 1155034 -

- -
-
-
- - diff --git a/dom/media/webspeech/synth/test/file_setup.html b/dom/media/webspeech/synth/test/file_setup.html deleted file mode 100644 index 4c1020505..000000000 --- a/dom/media/webspeech/synth/test/file_setup.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - Test for Bug 525444: Web Speech API check all classes are present - - - - -Mozilla Bug 650295 -

- -
-
-
- - diff --git a/dom/media/webspeech/synth/test/file_speech_cancel.html b/dom/media/webspeech/synth/test/file_speech_cancel.html deleted file mode 100644 index 2ab0e1d0a..000000000 --- a/dom/media/webspeech/synth/test/file_speech_cancel.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - Test for Bug 1150315: Check that successive cancel/speak calls work - - - - -Mozilla Bug 1150315 -

- -
-
-
- - diff --git a/dom/media/webspeech/synth/test/file_speech_error.html b/dom/media/webspeech/synth/test/file_speech_error.html deleted file mode 100644 index b98ec2fac..000000000 --- a/dom/media/webspeech/synth/test/file_speech_error.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - Test for Bug 1226015 - - - - -Mozilla Bug 1226015 -

- -
-
-
- - diff --git a/dom/media/webspeech/synth/test/file_speech_queue.html b/dom/media/webspeech/synth/test/file_speech_queue.html deleted file mode 100644 index e308f35e5..000000000 --- a/dom/media/webspeech/synth/test/file_speech_queue.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - Test for Bug 525444: Web Speech API, check speech synth queue - - - - -Mozilla Bug 525444 -

- -
-
-
- - diff --git a/dom/media/webspeech/synth/test/file_speech_simple.html b/dom/media/webspeech/synth/test/file_speech_simple.html deleted file mode 100644 index c3f240ccd..000000000 --- a/dom/media/webspeech/synth/test/file_speech_simple.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - Test for Bug 650295: Web Speech API check all classes are present - - - - -Mozilla Bug 650295 -

- -
-
-
- - diff --git a/dom/media/webspeech/synth/test/mochitest.ini b/dom/media/webspeech/synth/test/mochitest.ini deleted file mode 100644 index f27cd4e1b..000000000 --- a/dom/media/webspeech/synth/test/mochitest.ini +++ /dev/null @@ -1,26 +0,0 @@ -[DEFAULT] -tags=msg -subsuite = media -support-files = - common.js - file_bfcache_frame.html - file_setup.html - file_speech_queue.html - file_speech_simple.html - file_speech_cancel.html - file_speech_error.html - file_indirect_service_events.html - file_global_queue.html - file_global_queue_cancel.html - file_global_queue_pause.html - -[test_setup.html] -[test_speech_queue.html] -[test_speech_simple.html] -[test_speech_cancel.html] -[test_speech_error.html] -[test_indirect_service_events.html] -[test_global_queue.html] -[test_global_queue_cancel.html] -[test_global_queue_pause.html] -[test_bfcache.html] diff --git a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp deleted file mode 100644 index 582ff3551..000000000 --- a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp +++ /dev/null @@ -1,401 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.h" -#include "nsFakeSynthServices.h" -#include "nsPrintfCString.h" -#include "nsIWeakReferenceUtils.h" -#include "SharedBuffer.h" -#include "nsISimpleEnumerator.h" - -#include "mozilla/dom/nsSynthVoiceRegistry.h" -#include "mozilla/dom/nsSpeechTask.h" - -#include "nsThreadUtils.h" -#include "prenv.h" -#include "mozilla/Preferences.h" -#include "mozilla/DebugOnly.h" - -#define CHANNELS 1 -#define SAMPLERATE 1600 - -namespace mozilla { -namespace dom { - -StaticRefPtr nsFakeSynthServices::sSingleton; - -enum VoiceFlags -{ - eSuppressEvents = 1, - eSuppressEnd = 2, - eFailAtStart = 4, - eFail = 8 -}; - -struct VoiceDetails -{ - const char* uri; - const char* name; - const char* lang; - bool defaultVoice; - uint32_t flags; -}; - -static const VoiceDetails sDirectVoices[] = { - {"urn:moz-tts:fake-direct:bob", "Bob Marley", "en-JM", true, 0}, - {"urn:moz-tts:fake-direct:amy", "Amy Winehouse", "en-GB", false, 0}, - {"urn:moz-tts:fake-direct:lenny", "Leonard Cohen", "en-CA", false, 0}, - {"urn:moz-tts:fake-direct:celine", "Celine Dion", "fr-CA", false, 0}, - {"urn:moz-tts:fake-direct:julie", "Julieta Venegas", "es-MX", false, }, -}; - -static const VoiceDetails sIndirectVoices[] = { - {"urn:moz-tts:fake-indirect:zanetta", "Zanetta Farussi", "it-IT", false, 0}, - {"urn:moz-tts:fake-indirect:margherita", "Margherita Durastanti", "it-IT-noevents-noend", false, eSuppressEvents | eSuppressEnd}, - {"urn:moz-tts:fake-indirect:teresa", "Teresa Cornelys", "it-IT-noend", false, eSuppressEnd}, - {"urn:moz-tts:fake-indirect:cecilia", "Cecilia Bartoli", "it-IT-failatstart", false, eFailAtStart}, - {"urn:moz-tts:fake-indirect:gottardo", "Gottardo Aldighieri", "it-IT-fail", false, eFail}, -}; - -// FakeSynthCallback -class FakeSynthCallback : public nsISpeechTaskCallback -{ -public: - explicit FakeSynthCallback(nsISpeechTask* aTask) : mTask(aTask) { } - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(FakeSynthCallback, nsISpeechTaskCallback) - - NS_IMETHOD OnPause() override - { - if (mTask) { - mTask->DispatchPause(1.5, 1); - } - - return NS_OK; - } - - NS_IMETHOD OnResume() override - { - if (mTask) { - mTask->DispatchResume(1.5, 1); - } - - return NS_OK; - } - - NS_IMETHOD OnCancel() override - { - if (mTask) { - mTask->DispatchEnd(1.5, 1); - } - - return NS_OK; - } - - NS_IMETHOD OnVolumeChanged(float aVolume) override - { - return NS_OK; - } - -private: - virtual ~FakeSynthCallback() { } - - nsCOMPtr mTask; -}; - -NS_IMPL_CYCLE_COLLECTION(FakeSynthCallback, mTask); - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FakeSynthCallback) - NS_INTERFACE_MAP_ENTRY(nsISpeechTaskCallback) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISpeechTaskCallback) -NS_INTERFACE_MAP_END - -NS_IMPL_CYCLE_COLLECTING_ADDREF(FakeSynthCallback) -NS_IMPL_CYCLE_COLLECTING_RELEASE(FakeSynthCallback) - -// FakeDirectAudioSynth - -class FakeDirectAudioSynth : public nsISpeechService -{ - -public: - FakeDirectAudioSynth() { } - - NS_DECL_ISUPPORTS - NS_DECL_NSISPEECHSERVICE - -private: - virtual ~FakeDirectAudioSynth() { } -}; - -NS_IMPL_ISUPPORTS(FakeDirectAudioSynth, nsISpeechService) - -NS_IMETHODIMP -FakeDirectAudioSynth::Speak(const nsAString& aText, const nsAString& aUri, - float aVolume, float aRate, float aPitch, - nsISpeechTask* aTask) -{ - class Runnable final : public mozilla::Runnable - { - public: - Runnable(nsISpeechTask* aTask, const nsAString& aText) : - mTask(aTask), mText(aText) - { - } - - NS_IMETHOD Run() override - { - RefPtr cb = new FakeSynthCallback(nullptr); - mTask->Setup(cb, CHANNELS, SAMPLERATE, 2); - - // Just an arbitrary multiplier. Pretend that each character is - // synthesized to 40 frames. - uint32_t frames_length = 40 * mText.Length(); - auto frames = MakeUnique(frames_length); - mTask->SendAudioNative(frames.get(), frames_length); - - mTask->SendAudioNative(nullptr, 0); - - return NS_OK; - } - - private: - nsCOMPtr mTask; - nsString mText; - }; - - nsCOMPtr runnable = new Runnable(aTask, aText); - NS_DispatchToMainThread(runnable); - return NS_OK; -} - -NS_IMETHODIMP -FakeDirectAudioSynth::GetServiceType(SpeechServiceType* aServiceType) -{ - *aServiceType = nsISpeechService::SERVICETYPE_DIRECT_AUDIO; - return NS_OK; -} - -// FakeDirectAudioSynth - -class FakeIndirectAudioSynth : public nsISpeechService -{ - -public: - FakeIndirectAudioSynth() {} - - NS_DECL_ISUPPORTS - NS_DECL_NSISPEECHSERVICE - -private: - virtual ~FakeIndirectAudioSynth() { } -}; - -NS_IMPL_ISUPPORTS(FakeIndirectAudioSynth, nsISpeechService) - -NS_IMETHODIMP -FakeIndirectAudioSynth::Speak(const nsAString& aText, const nsAString& aUri, - float aVolume, float aRate, float aPitch, - nsISpeechTask* aTask) -{ - class DispatchStart final : public Runnable - { - public: - explicit DispatchStart(nsISpeechTask* aTask) : - mTask(aTask) - { - } - - NS_IMETHOD Run() override - { - mTask->DispatchStart(); - - return NS_OK; - } - - private: - nsCOMPtr mTask; - }; - - class DispatchEnd final : public Runnable - { - public: - DispatchEnd(nsISpeechTask* aTask, const nsAString& aText) : - mTask(aTask), mText(aText) - { - } - - NS_IMETHOD Run() override - { - mTask->DispatchEnd(mText.Length()/2, mText.Length()); - - return NS_OK; - } - - private: - nsCOMPtr mTask; - nsString mText; - }; - - class DispatchError final : public Runnable - { - public: - DispatchError(nsISpeechTask* aTask, const nsAString& aText) : - mTask(aTask), mText(aText) - { - } - - NS_IMETHOD Run() override - { - mTask->DispatchError(mText.Length()/2, mText.Length()); - - return NS_OK; - } - - private: - nsCOMPtr mTask; - nsString mText; - }; - - uint32_t flags = 0; - for (uint32_t i = 0; i < ArrayLength(sIndirectVoices); i++) { - if (aUri.EqualsASCII(sIndirectVoices[i].uri)) { - flags = sIndirectVoices[i].flags; - } - } - - if (flags & eFailAtStart) { - return NS_ERROR_FAILURE; - } - - RefPtr cb = new FakeSynthCallback( - (flags & eSuppressEvents) ? nullptr : aTask); - - aTask->Setup(cb, 0, 0, 0); - - nsCOMPtr runnable = new DispatchStart(aTask); - NS_DispatchToMainThread(runnable); - - if (flags & eFail) { - runnable = new DispatchError(aTask, aText); - NS_DispatchToMainThread(runnable); - } else if ((flags & eSuppressEnd) == 0) { - runnable = new DispatchEnd(aTask, aText); - NS_DispatchToMainThread(runnable); - } - - return NS_OK; -} - -NS_IMETHODIMP -FakeIndirectAudioSynth::GetServiceType(SpeechServiceType* aServiceType) -{ - *aServiceType = nsISpeechService::SERVICETYPE_INDIRECT_AUDIO; - return NS_OK; -} - -// nsFakeSynthService - -NS_INTERFACE_MAP_BEGIN(nsFakeSynthServices) - NS_INTERFACE_MAP_ENTRY(nsIObserver) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver) -NS_INTERFACE_MAP_END - -NS_IMPL_ADDREF(nsFakeSynthServices) -NS_IMPL_RELEASE(nsFakeSynthServices) - -nsFakeSynthServices::nsFakeSynthServices() -{ -} - -nsFakeSynthServices::~nsFakeSynthServices() -{ -} - -static void -AddVoices(nsISpeechService* aService, const VoiceDetails* aVoices, uint32_t aLength) -{ - RefPtr registry = nsSynthVoiceRegistry::GetInstance(); - for (uint32_t i = 0; i < aLength; i++) { - NS_ConvertUTF8toUTF16 name(aVoices[i].name); - NS_ConvertUTF8toUTF16 uri(aVoices[i].uri); - NS_ConvertUTF8toUTF16 lang(aVoices[i].lang); - // These services can handle more than one utterance at a time and have - // several speaking simultaniously. So, aQueuesUtterances == false - registry->AddVoice(aService, uri, name, lang, true, false); - if (aVoices[i].defaultVoice) { - registry->SetDefaultVoice(uri, true); - } - } - - registry->NotifyVoicesChanged(); -} - -void -nsFakeSynthServices::Init() -{ - mDirectService = new FakeDirectAudioSynth(); - AddVoices(mDirectService, sDirectVoices, ArrayLength(sDirectVoices)); - - mIndirectService = new FakeIndirectAudioSynth(); - AddVoices(mIndirectService, sIndirectVoices, ArrayLength(sIndirectVoices)); -} - -// nsIObserver - -NS_IMETHODIMP -nsFakeSynthServices::Observe(nsISupports* aSubject, const char* aTopic, - const char16_t* aData) -{ - MOZ_ASSERT(NS_IsMainThread()); - if(NS_WARN_IF(!(!strcmp(aTopic, "speech-synth-started")))) { - return NS_ERROR_UNEXPECTED; - } - - if (Preferences::GetBool("media.webspeech.synth.test")) { - NS_DispatchToMainThread(NewRunnableMethod(this, &nsFakeSynthServices::Init)); - } - - return NS_OK; -} - -// static methods - -nsFakeSynthServices* -nsFakeSynthServices::GetInstance() -{ - MOZ_ASSERT(NS_IsMainThread()); - if (!XRE_IsParentProcess()) { - MOZ_ASSERT(false, "nsFakeSynthServices can only be started on main gecko process"); - return nullptr; - } - - if (!sSingleton) { - sSingleton = new nsFakeSynthServices(); - } - - return sSingleton; -} - -already_AddRefed -nsFakeSynthServices::GetInstanceForService() -{ - RefPtr picoService = GetInstance(); - return picoService.forget(); -} - -void -nsFakeSynthServices::Shutdown() -{ - if (!sSingleton) { - return; - } - - sSingleton = nullptr; -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/media/webspeech/synth/test/nsFakeSynthServices.h b/dom/media/webspeech/synth/test/nsFakeSynthServices.h deleted file mode 100644 index bab93e779..000000000 --- a/dom/media/webspeech/synth/test/nsFakeSynthServices.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsFakeSynthServices_h -#define nsFakeSynthServices_h - -#include "nsTArray.h" -#include "nsIObserver.h" -#include "nsIThread.h" -#include "nsISpeechService.h" -#include "nsRefPtrHashtable.h" -#include "mozilla/StaticPtr.h" -#include "mozilla/Monitor.h" - -namespace mozilla { -namespace dom { - -class nsFakeSynthServices : public nsIObserver -{ - -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - - nsFakeSynthServices(); - - static nsFakeSynthServices* GetInstance(); - - static already_AddRefed GetInstanceForService(); - - static void Shutdown(); - -private: - - virtual ~nsFakeSynthServices(); - - void Init(); - - nsCOMPtr mDirectService; - - nsCOMPtr mIndirectService; - - static StaticRefPtr sSingleton; -}; - -} // namespace dom -} // namespace mozilla - -#endif diff --git a/dom/media/webspeech/synth/test/startup/file_voiceschanged.html b/dom/media/webspeech/synth/test/startup/file_voiceschanged.html deleted file mode 100644 index 6bb25462e..000000000 --- a/dom/media/webspeech/synth/test/startup/file_voiceschanged.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - Test for Bug 1254378: Web Speech API check all classes are present - - - - - - diff --git a/dom/media/webspeech/synth/test/startup/mochitest.ini b/dom/media/webspeech/synth/test/startup/mochitest.ini deleted file mode 100644 index 7312a71eb..000000000 --- a/dom/media/webspeech/synth/test/startup/mochitest.ini +++ /dev/null @@ -1,7 +0,0 @@ -[DEFAULT] -tags=msg -subsuite = media -support-files = - file_voiceschanged.html - -[test_voiceschanged.html] diff --git a/dom/media/webspeech/synth/test/startup/test_voiceschanged.html b/dom/media/webspeech/synth/test/startup/test_voiceschanged.html deleted file mode 100644 index 079938c35..000000000 --- a/dom/media/webspeech/synth/test/startup/test_voiceschanged.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - Test for Bug 1254378: Emit onvoiceschanged when voices first added - - - - -Mozilla Bug 1254378 -

- - -
-
-
- - diff --git a/dom/media/webspeech/synth/test/test_bfcache.html b/dom/media/webspeech/synth/test/test_bfcache.html deleted file mode 100644 index 8681def3f..000000000 --- a/dom/media/webspeech/synth/test/test_bfcache.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - Test for Bug 1230533: Test speech is stopped from a window when unloaded - - - - - -Mozilla Bug 1230533 -

- - -
-
-
- - diff --git a/dom/media/webspeech/synth/test/test_global_queue.html b/dom/media/webspeech/synth/test/test_global_queue.html deleted file mode 100644 index 34d3a4ed3..000000000 --- a/dom/media/webspeech/synth/test/test_global_queue.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - Test for Bug 1188099: Global queue should correctly schedule utterances - - - - - -Mozilla Bug 1188099 -

- - -
-
-
- - \ No newline at end of file diff --git a/dom/media/webspeech/synth/test/test_global_queue_cancel.html b/dom/media/webspeech/synth/test/test_global_queue_cancel.html deleted file mode 100644 index 4c5c11634..000000000 --- a/dom/media/webspeech/synth/test/test_global_queue_cancel.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - Test for Bug 1188099: Calling cancel() should work correctly with global queue - - - - - -Mozilla Bug 1188099 -

- - -
-
-
- - \ No newline at end of file diff --git a/dom/media/webspeech/synth/test/test_global_queue_pause.html b/dom/media/webspeech/synth/test/test_global_queue_pause.html deleted file mode 100644 index f5ac1b98c..000000000 --- a/dom/media/webspeech/synth/test/test_global_queue_pause.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - Test for Bug 1188099: Calling pause() should work correctly with global queue - - - - - -Mozilla Bug 1188099 -

- - -
-
-
- - \ No newline at end of file diff --git a/dom/media/webspeech/synth/test/test_indirect_service_events.html b/dom/media/webspeech/synth/test/test_indirect_service_events.html deleted file mode 100644 index d7f5ec424..000000000 --- a/dom/media/webspeech/synth/test/test_indirect_service_events.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - Test for Bug 1155034: Check that indirect audio services dispatch their own events - - - - - -Mozilla Bug 1155034 -

- - -
-
-
- - diff --git a/dom/media/webspeech/synth/test/test_setup.html b/dom/media/webspeech/synth/test/test_setup.html deleted file mode 100644 index 6286b6c2e..000000000 --- a/dom/media/webspeech/synth/test/test_setup.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - Test for Bug 525444: Web Speech API check all classes are present - - - - -Mozilla Bug 650295 -

- - -
-
-
- - diff --git a/dom/media/webspeech/synth/test/test_speech_cancel.html b/dom/media/webspeech/synth/test/test_speech_cancel.html deleted file mode 100644 index e7cf051ef..000000000 --- a/dom/media/webspeech/synth/test/test_speech_cancel.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - Test for Bug 1150315: Web Speech API check all classes are present - - - - - -Mozilla Bug 1150315 -

- - -
-
-
- - diff --git a/dom/media/webspeech/synth/test/test_speech_error.html b/dom/media/webspeech/synth/test/test_speech_error.html deleted file mode 100644 index c4bfdc6c4..000000000 --- a/dom/media/webspeech/synth/test/test_speech_error.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - Test for Bug 1150315: Web Speech API check all classes are present - - - - - -Mozilla Bug 1226015 -

- - -
-
-
- - diff --git a/dom/media/webspeech/synth/test/test_speech_queue.html b/dom/media/webspeech/synth/test/test_speech_queue.html deleted file mode 100644 index ca652b243..000000000 --- a/dom/media/webspeech/synth/test/test_speech_queue.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - Test for Bug 525444: Web Speech API, check speech synth queue - - - - - -Mozilla Bug 525444 -

- - -
-
-
- - diff --git a/dom/media/webspeech/synth/test/test_speech_simple.html b/dom/media/webspeech/synth/test/test_speech_simple.html deleted file mode 100644 index 2eb75af43..000000000 --- a/dom/media/webspeech/synth/test/test_speech_simple.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - Test for Bug 650295: Web Speech API check all classes are present - - - - - -Mozilla Bug 650295 -

- - -
-
-
- - -- cgit v1.2.3