diff options
author | Moonchild <moonchild@palemoon.org> | 2020-05-20 10:19:04 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-05-20 14:04:17 +0000 |
commit | 99c2e698d2a3c56649e42d8d2133706cd8c9501e (patch) | |
tree | 85be449d772eb57860f0f386efb4bc1e790fd498 /dom/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp | |
parent | 15ac4021b06d549e47c9e2efc9364a9eb96bfe82 (diff) | |
download | UXP-99c2e698d2a3c56649e42d8d2133706cd8c9501e.tar UXP-99c2e698d2a3c56649e42d8d2133706cd8c9501e.tar.gz UXP-99c2e698d2a3c56649e42d8d2133706cd8c9501e.tar.lz UXP-99c2e698d2a3c56649e42d8d2133706cd8c9501e.tar.xz UXP-99c2e698d2a3c56649e42d8d2133706cd8c9501e.zip |
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
Diffstat (limited to 'dom/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp')
-rw-r--r-- | dom/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/dom/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp b/dom/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp deleted file mode 100644 index 97bf4b998..000000000 --- a/dom/media/webspeech/recognition/test/FakeSpeechRecognitionService.cpp +++ /dev/null @@ -1,119 +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 "nsThreadUtils.h" - -#include "FakeSpeechRecognitionService.h" -#include "MediaPrefs.h" - -#include "SpeechRecognition.h" -#include "SpeechRecognitionAlternative.h" -#include "SpeechRecognitionResult.h" -#include "SpeechRecognitionResultList.h" -#include "nsIObserverService.h" -#include "mozilla/Services.h" - -namespace mozilla { - -using namespace dom; - -NS_IMPL_ISUPPORTS(FakeSpeechRecognitionService, nsISpeechRecognitionService, nsIObserver) - -FakeSpeechRecognitionService::FakeSpeechRecognitionService() -{ -} - -FakeSpeechRecognitionService::~FakeSpeechRecognitionService() -{ -} - -NS_IMETHODIMP -FakeSpeechRecognitionService::Initialize(WeakPtr<SpeechRecognition> aSpeechRecognition) -{ - mRecognition = aSpeechRecognition; - nsCOMPtr<nsIObserverService> obs = services::GetObserverService(); - obs->AddObserver(this, SPEECH_RECOGNITION_TEST_EVENT_REQUEST_TOPIC, false); - obs->AddObserver(this, SPEECH_RECOGNITION_TEST_END_TOPIC, false); - return NS_OK; -} - -NS_IMETHODIMP -FakeSpeechRecognitionService::ProcessAudioSegment(AudioSegment* aAudioSegment, int32_t aSampleRate) -{ - return NS_OK; -} - -NS_IMETHODIMP -FakeSpeechRecognitionService::SoundEnd() -{ - return NS_OK; -} - -NS_IMETHODIMP -FakeSpeechRecognitionService::ValidateAndSetGrammarList(mozilla::dom::SpeechGrammar*, nsISpeechGrammarCompilationCallback*) -{ - return NS_OK; -} - -NS_IMETHODIMP -FakeSpeechRecognitionService::Abort() -{ - return NS_OK; -} - -NS_IMETHODIMP -FakeSpeechRecognitionService::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) -{ - MOZ_ASSERT(MediaPrefs::WebSpeechFakeRecognitionService(), - "Got request to fake recognition service event, but " - TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE " is not set"); - - if (!strcmp(aTopic, SPEECH_RECOGNITION_TEST_END_TOPIC)) { - nsCOMPtr<nsIObserverService> obs = services::GetObserverService(); - obs->RemoveObserver(this, SPEECH_RECOGNITION_TEST_EVENT_REQUEST_TOPIC); - obs->RemoveObserver(this, SPEECH_RECOGNITION_TEST_END_TOPIC); - - return NS_OK; - } - - const nsDependentString eventName = nsDependentString(aData); - - if (eventName.EqualsLiteral("EVENT_RECOGNITIONSERVICE_ERROR")) { - mRecognition->DispatchError(SpeechRecognition::EVENT_RECOGNITIONSERVICE_ERROR, - SpeechRecognitionErrorCode::Network, // TODO different codes? - NS_LITERAL_STRING("RECOGNITIONSERVICE_ERROR test event")); - - } else if (eventName.EqualsLiteral("EVENT_RECOGNITIONSERVICE_FINAL_RESULT")) { - RefPtr<SpeechEvent> event = - new SpeechEvent(mRecognition, - SpeechRecognition::EVENT_RECOGNITIONSERVICE_FINAL_RESULT); - - event->mRecognitionResultList = BuildMockResultList(); - NS_DispatchToMainThread(event); - } - - return NS_OK; -} - -SpeechRecognitionResultList* -FakeSpeechRecognitionService::BuildMockResultList() -{ - SpeechRecognitionResultList* resultList = new SpeechRecognitionResultList(mRecognition); - SpeechRecognitionResult* result = new SpeechRecognitionResult(mRecognition); - if (0 < mRecognition->MaxAlternatives()) { - SpeechRecognitionAlternative* alternative = new SpeechRecognitionAlternative(mRecognition); - - alternative->mTranscript = NS_LITERAL_STRING("Mock final result"); - alternative->mConfidence = 0.0f; - - result->mItems.AppendElement(alternative); - } - resultList->mItems.AppendElement(result); - - return resultList; -} - -} // namespace mozilla |