diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-21 21:51:43 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-21 21:51:43 +0000 |
commit | bd141d8f9578d87ebe7198c94186ba2ce2711312 (patch) | |
tree | 42aa948a353b49df7d276765b1a7f1d9d1b4f82b /chrome/browser/speech/speech_recognizer.cc | |
parent | b09df81df72de5476a35431d2b1f3793d48ef4f6 (diff) | |
download | chromium_src-bd141d8f9578d87ebe7198c94186ba2ce2711312.zip chromium_src-bd141d8f9578d87ebe7198c94186ba2ce2711312.tar.gz chromium_src-bd141d8f9578d87ebe7198c94186ba2ce2711312.tar.bz2 |
Extend speech input bubble in Mac to display error messages with try-again and cancel buttons.
The SpeechInputBubbleImpl object now lives longer than the actual info bubble window, and
allows the caller to create a bubble on screen or update with an error message when needed.
When recording speech, the layout of controls are (vertical):
- Label ('Speak now')
- Icon (Mic or wait)
- Button Bar (Horizontal, 1 button, 'Cancel')
When showing a message, the layout of controls are (vertical):
- Label (message text)
- Button Bar (Horizontal, 2 buttons, 'Try Again' and 'Cancel')
Also made a small correction to the info bubble's anchor point to get the arrow point at the correct starting point of the given element rect.
XIB changes:
- Added a 'try again' button and hooked it up to the tryAgainButton outlet in the controller
- Moved position of the cancel button for easier editing in interface builder
BUG=53598
TEST=manual, unplug mic and start recognition to check error message, and similarly give no speech to check.
Review URL: http://codereview.chromium.org/3438002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60112 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/speech/speech_recognizer.cc')
-rw-r--r-- | chrome/browser/speech/speech_recognizer.cc | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/chrome/browser/speech/speech_recognizer.cc b/chrome/browser/speech/speech_recognizer.cc index 6eed2f5..ce1bfaa 100644 --- a/chrome/browser/speech/speech_recognizer.cc +++ b/chrome/browser/speech/speech_recognizer.cc @@ -31,11 +31,11 @@ COMPILE_ASSERT(kMaxSpeexFrameLength <= 0xFF, invalidLength); // The following constants are related to the volume level indicator shown in // the UI for recorded audio. // Multiplier used when new volume is greater than previous level. -const float kUpSmoothingFactor = 0.9f;
-// Multiplier used when new volume is lesser than previous level.
-const float kDownSmoothingFactor = 0.4f;
-const float kAudioMeterMinDb = 10.0f; // Lower bar for volume meter.
-const float kAudioMeterDbRange = 25.0f;
+const float kUpSmoothingFactor = 0.9f; +// Multiplier used when new volume is lesser than previous level. +const float kDownSmoothingFactor = 0.4f; +const float kAudioMeterMinDb = 10.0f; // Lower bar for volume meter. +const float kAudioMeterDbRange = 25.0f; } // namespace namespace speech_input { @@ -293,13 +293,13 @@ void SpeechRecognizer::HandleOnData(string* data) { // Calculate the input volume to display in the UI, smoothing towards the // new level. - float level = (rms - kAudioMeterMinDb) / kAudioMeterDbRange;
- level = std::min(std::max(0.0f, level), 1.0f);
- if (level > audio_level_) {
- audio_level_ += (level - audio_level_) * kUpSmoothingFactor;
- } else {
- audio_level_ += (level - audio_level_) * kDownSmoothingFactor;
- }
+ float level = (rms - kAudioMeterMinDb) / kAudioMeterDbRange; + level = std::min(std::max(0.0f, level), 1.0f); + if (level > audio_level_) { + audio_level_ += (level - audio_level_) * kUpSmoothingFactor; + } else { + audio_level_ += (level - audio_level_) * kDownSmoothingFactor; + } delegate_->SetInputVolume(caller_id_, audio_level_); if (endpointer_.speech_input_complete()) { |