diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-28 08:47:09 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-28 08:47:09 +0000 |
commit | befab4b7c401a2368fe313db1be59c83626c6b36 (patch) | |
tree | 07abbabbe42a391265c21d0f843c86d122abec96 /chrome/browser/speech/speech_recognizer.cc | |
parent | 2ae27702b4bd9bf31a19024131ba701c9253297c (diff) | |
download | chromium_src-befab4b7c401a2368fe313db1be59c83626c6b36.zip chromium_src-befab4b7c401a2368fe313db1be59c83626c6b36.tar.gz chromium_src-befab4b7c401a2368fe313db1be59c83626c6b36.tar.bz2 |
Added grammar attribute to speech input.
In https://bugs.webkit.org/show_bug.cgi?id=48339 we added support for a 'x-webkit-grammar' attribute for speech input.
In this CL we receive that as a parameter to SpeechInputDispatcher::startRecognition() and pass it up to the
SpeechRecognitionRequest object which encodes and sends it as a url parameter to the server.
To aid in this I also moved the speech server URL from SpeechRecognizer.cc to SpeechRecognitionRequest.cc.
Also added a browser test for this attribute. It is marked as FLAKY now because the code is exactly the same as with
the TestBasicRecognition test in that file and that test is FLAKY now. Both are marked with the same bug and I will
remove the FLAKY_ prefix on both when the bug is closed.
BUG=none
TEST=browser_tests --gtest_filter=SpeechInputBrowserTest.GrammarAttribute
Review URL: http://codereview.chromium.org/4183002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/speech/speech_recognizer.cc')
-rw-r--r-- | chrome/browser/speech/speech_recognizer.cc | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/chrome/browser/speech/speech_recognizer.cc b/chrome/browser/speech/speech_recognizer.cc index 580339a..2852c5e 100644 --- a/chrome/browser/speech/speech_recognizer.cc +++ b/chrome/browser/speech/speech_recognizer.cc @@ -17,8 +17,6 @@ using std::list; using std::string; namespace { -const char* const kDefaultSpeechRecognitionUrl = - "http://www.google.com/speech-api/v1/recognize?lang=en-us&client=chromium"; const char* const kContentTypeSpeex = "audio/x-speex-with-header-byte; rate=16000"; const int kSpeexEncodingQuality = 8; @@ -109,9 +107,12 @@ void SpeexEncoder::Encode(const short* samples, } } -SpeechRecognizer::SpeechRecognizer(Delegate* delegate, int caller_id) +SpeechRecognizer::SpeechRecognizer(Delegate* delegate, + int caller_id, + const std::string& grammar) : delegate_(delegate), caller_id_(caller_id), + grammar_(grammar), encoder_(new SpeexEncoder()), endpointer_(kAudioSampleRate), num_samples_recorded_(0), @@ -211,10 +212,8 @@ void SpeechRecognizer::StopRecording() { } DCHECK(!request_.get()); request_.reset(new SpeechRecognitionRequest( - Profile::GetDefaultRequestContext(), - GURL(kDefaultSpeechRecognitionUrl), - this)); - request_->Send(kContentTypeSpeex, data); + Profile::GetDefaultRequestContext(), this)); + request_->Send(grammar_, kContentTypeSpeex, data); ReleaseAudioBuffers(); // No need to keep the audio anymore. } |