OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/speech/google_streaming_remote_engine.h" | 5 #include "content/browser/speech/google_streaming_remote_engine.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 break; | 442 break; |
443 case proto::SpeechRecognitionEvent::STATUS_NO_SPEECH: | 443 case proto::SpeechRecognitionEvent::STATUS_NO_SPEECH: |
444 return Abort(SPEECH_RECOGNITION_ERROR_NO_SPEECH); | 444 return Abort(SPEECH_RECOGNITION_ERROR_NO_SPEECH); |
445 case proto::SpeechRecognitionEvent::STATUS_ABORTED: | 445 case proto::SpeechRecognitionEvent::STATUS_ABORTED: |
446 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); | 446 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); |
447 case proto::SpeechRecognitionEvent::STATUS_AUDIO_CAPTURE: | 447 case proto::SpeechRecognitionEvent::STATUS_AUDIO_CAPTURE: |
448 return Abort(SPEECH_RECOGNITION_ERROR_AUDIO); | 448 return Abort(SPEECH_RECOGNITION_ERROR_AUDIO); |
449 case proto::SpeechRecognitionEvent::STATUS_NETWORK: | 449 case proto::SpeechRecognitionEvent::STATUS_NETWORK: |
450 return Abort(SPEECH_RECOGNITION_ERROR_NETWORK); | 450 return Abort(SPEECH_RECOGNITION_ERROR_NETWORK); |
451 case proto::SpeechRecognitionEvent::STATUS_NOT_ALLOWED: | 451 case proto::SpeechRecognitionEvent::STATUS_NOT_ALLOWED: |
452 // TODO(hans): We need a better error code for this. | 452 return Abort(SPEECH_RECOGNITION_ERROR_NOT_ALLOWED); |
453 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); | |
454 case proto::SpeechRecognitionEvent::STATUS_SERVICE_NOT_ALLOWED: | 453 case proto::SpeechRecognitionEvent::STATUS_SERVICE_NOT_ALLOWED: |
455 // TODO(hans): We need a better error code for this. | 454 return Abort(SPEECH_RECOGNITION_ERROR_SERVICE_NOT_ALLOWED); |
456 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); | |
457 case proto::SpeechRecognitionEvent::STATUS_BAD_GRAMMAR: | 455 case proto::SpeechRecognitionEvent::STATUS_BAD_GRAMMAR: |
458 return Abort(SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR); | 456 return Abort(SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR); |
459 case proto::SpeechRecognitionEvent::STATUS_LANGUAGE_NOT_SUPPORTED: | 457 case proto::SpeechRecognitionEvent::STATUS_LANGUAGE_NOT_SUPPORTED: |
460 // TODO(hans): We need a better error code for this. | 458 return Abort(SPEECH_RECOGNITION_ERROR_LANGUAGE_NOT_SUPPORTED); |
461 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); | |
462 } | 459 } |
463 } | 460 } |
464 | 461 |
465 SpeechRecognitionResults results; | 462 SpeechRecognitionResults results; |
466 for (int i = 0; i < ws_event.result_size(); ++i) { | 463 for (int i = 0; i < ws_event.result_size(); ++i) { |
467 const proto::SpeechRecognitionResult& ws_result = ws_event.result(i); | 464 const proto::SpeechRecognitionResult& ws_result = ws_event.result(i); |
468 results.push_back(SpeechRecognitionResult()); | 465 results.push_back(SpeechRecognitionResult()); |
469 SpeechRecognitionResult& result = results.back(); | 466 SpeechRecognitionResult& result = results.back(); |
470 result.is_provisional = !(ws_result.has_final() && ws_result.final()); | 467 result.is_provisional = !(ws_result.has_final() && ws_result.final()); |
471 | 468 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 } | 628 } |
632 | 629 |
633 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value) | 630 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value) |
634 : event(event_value) { | 631 : event(event_value) { |
635 } | 632 } |
636 | 633 |
637 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() { | 634 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() { |
638 } | 635 } |
639 | 636 |
640 } // namespace content | 637 } // namespace content |
OLD | NEW |