diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-29 11:57:18 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-29 11:57:18 +0000 |
commit | fcb8e0216c21719582f25726cf4f6766b1902f64 (patch) | |
tree | 1d14bc15659799f45740df07dc918e961601159d /content/browser/speech/google_streaming_remote_engine.cc | |
parent | 8b81e050226de9b2f7614557e12c13fc3f3690eb (diff) | |
download | chromium_src-fcb8e0216c21719582f25726cf4f6766b1902f64.zip chromium_src-fcb8e0216c21719582f25726cf4f6766b1902f64.tar.gz chromium_src-fcb8e0216c21719582f25726cf4f6766b1902f64.tar.bz2 |
content/browser: Move speech code into content namespace.
TBR=jam@chromium.org
Review URL: https://codereview.chromium.org/11347004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/speech/google_streaming_remote_engine.cc')
-rw-r--r-- | content/browser/speech/google_streaming_remote_engine.cc | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/content/browser/speech/google_streaming_remote_engine.cc b/content/browser/speech/google_streaming_remote_engine.cc index 66bd9e6..2f050bd 100644 --- a/content/browser/speech/google_streaming_remote_engine.cc +++ b/content/browser/speech/google_streaming_remote_engine.cc @@ -27,13 +27,9 @@ #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_status.h" -using content::BrowserThread; -using content::SpeechRecognitionError; -using content::SpeechRecognitionErrorCode; -using content::SpeechRecognitionHypothesis; -using content::SpeechRecognitionResult; using net::URLFetcher; +namespace content { namespace { const char kWebServiceBaseUrl[] = @@ -41,8 +37,7 @@ const char kWebServiceBaseUrl[] = const char kDownstreamUrl[] = "/down?"; const char kUpstreamUrl[] = "/up?"; const int kAudioPacketIntervalMs = 100; -const speech::AudioEncoder::Codec kDefaultAudioCodec = - speech::AudioEncoder::CODEC_FLAC; +const AudioEncoder::Codec kDefaultAudioCodec = AudioEncoder::CODEC_FLAC; // This mathces the maximum maxAlternatives value supported by the server. const uint32 kMaxMaxAlternatives = 30; @@ -50,7 +45,7 @@ const uint32 kMaxMaxAlternatives = 30; // TODO(hans): Remove this and other logging when we don't need it anymore. void DumpResponse(const std::string& response) { DVLOG(1) << "------------"; - speech::proto::SpeechRecognitionEvent event; + proto::SpeechRecognitionEvent event; if (!event.ParseFromString(response)) { DVLOG(1) << "Parse failed!"; return; @@ -59,13 +54,13 @@ void DumpResponse(const std::string& response) { DVLOG(1) << "STATUS\t" << event.status(); for (int i = 0; i < event.result_size(); ++i) { DVLOG(1) << "RESULT #" << i << ":"; - const speech::proto::SpeechRecognitionResult& res = event.result(i); + const proto::SpeechRecognitionResult& res = event.result(i); if (res.has_final()) DVLOG(1) << " FINAL:\t" << res.final(); if (res.has_stability()) DVLOG(1) << " STABILITY:\t" << res.stability(); for (int j = 0; j < res.alternative_size(); ++j) { - const speech::proto::SpeechRecognitionAlternative& alt = + const proto::SpeechRecognitionAlternative& alt = res.alternative(j); if (alt.has_confidence()) DVLOG(1) << " CONFIDENCE:\t" << alt.confidence(); @@ -92,8 +87,6 @@ std::string GetAPIKey() { } // namespace -namespace speech { - const int GoogleStreamingRemoteEngine::kUpstreamUrlFetcherIdForTests = 0; const int GoogleStreamingRemoteEngine::kDownstreamUrlFetcherIdForTests = 1; const int GoogleStreamingRemoteEngine::kWebserviceStatusNoError = 0; @@ -422,24 +415,24 @@ GoogleStreamingRemoteEngine::ProcessDownstreamResponse( case proto::SpeechRecognitionEvent::STATUS_SUCCESS: break; case proto::SpeechRecognitionEvent::STATUS_NO_SPEECH: - return Abort(content::SPEECH_RECOGNITION_ERROR_NO_SPEECH); + return Abort(SPEECH_RECOGNITION_ERROR_NO_SPEECH); case proto::SpeechRecognitionEvent::STATUS_ABORTED: - return Abort(content::SPEECH_RECOGNITION_ERROR_ABORTED); + return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); case proto::SpeechRecognitionEvent::STATUS_AUDIO_CAPTURE: - return Abort(content::SPEECH_RECOGNITION_ERROR_AUDIO); + return Abort(SPEECH_RECOGNITION_ERROR_AUDIO); case proto::SpeechRecognitionEvent::STATUS_NETWORK: - return Abort(content::SPEECH_RECOGNITION_ERROR_NETWORK); + return Abort(SPEECH_RECOGNITION_ERROR_NETWORK); case proto::SpeechRecognitionEvent::STATUS_NOT_ALLOWED: // TODO(hans): We need a better error code for this. - return Abort(content::SPEECH_RECOGNITION_ERROR_ABORTED); + return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); case proto::SpeechRecognitionEvent::STATUS_SERVICE_NOT_ALLOWED: // TODO(hans): We need a better error code for this. - return Abort(content::SPEECH_RECOGNITION_ERROR_ABORTED); + return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); case proto::SpeechRecognitionEvent::STATUS_BAD_GRAMMAR: - return Abort(content::SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR); + return Abort(SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR); case proto::SpeechRecognitionEvent::STATUS_LANGUAGE_NOT_SUPPORTED: // TODO(hans): We need a better error code for this. - return Abort(content::SPEECH_RECOGNITION_ERROR_ABORTED); + return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); } } @@ -524,19 +517,19 @@ GoogleStreamingRemoteEngine::CloseDownstream(const FSMEventArgs&) { GoogleStreamingRemoteEngine::FSMState GoogleStreamingRemoteEngine::AbortSilently(const FSMEventArgs&) { - return Abort(content::SPEECH_RECOGNITION_ERROR_NONE); + return Abort(SPEECH_RECOGNITION_ERROR_NONE); } GoogleStreamingRemoteEngine::FSMState GoogleStreamingRemoteEngine::AbortWithError(const FSMEventArgs&) { - return Abort(content::SPEECH_RECOGNITION_ERROR_NETWORK); + return Abort(SPEECH_RECOGNITION_ERROR_NETWORK); } GoogleStreamingRemoteEngine::FSMState GoogleStreamingRemoteEngine::Abort( SpeechRecognitionErrorCode error_code) { DVLOG(1) << "Aborting with error " << error_code; - if (error_code != content::SPEECH_RECOGNITION_ERROR_NONE) { + if (error_code != SPEECH_RECOGNITION_ERROR_NONE) { delegate()->OnSpeechRecognitionEngineError( SpeechRecognitionError(error_code)); } @@ -596,4 +589,4 @@ GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value) GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() { } -} // namespace speech +} // namespace content |