Import Chrome's tts code

This commit is contained in:
Cheng Zhao 2014-10-07 21:18:44 +08:00
parent 8519ea3299
commit 05b602d0ce
18 changed files with 2312 additions and 0 deletions

View file

@ -0,0 +1,69 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Multiply-included message file, hence no include guard.
#include <vector>
#include "chrome/common/tts_utterance_request.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_param_traits.h"
#define IPC_MESSAGE_START TtsMsgStart
IPC_STRUCT_TRAITS_BEGIN(TtsUtteranceRequest)
IPC_STRUCT_TRAITS_MEMBER(id)
IPC_STRUCT_TRAITS_MEMBER(text)
IPC_STRUCT_TRAITS_MEMBER(lang)
IPC_STRUCT_TRAITS_MEMBER(voice)
IPC_STRUCT_TRAITS_MEMBER(volume)
IPC_STRUCT_TRAITS_MEMBER(rate)
IPC_STRUCT_TRAITS_MEMBER(pitch)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(TtsVoice)
IPC_STRUCT_TRAITS_MEMBER(voice_uri)
IPC_STRUCT_TRAITS_MEMBER(name)
IPC_STRUCT_TRAITS_MEMBER(lang)
IPC_STRUCT_TRAITS_MEMBER(local_service)
IPC_STRUCT_TRAITS_MEMBER(is_default)
IPC_STRUCT_TRAITS_END()
// Renderer -> Browser messages.
IPC_MESSAGE_CONTROL0(TtsHostMsg_InitializeVoiceList)
IPC_MESSAGE_CONTROL1(TtsHostMsg_Speak,
TtsUtteranceRequest)
IPC_MESSAGE_CONTROL0(TtsHostMsg_Pause)
IPC_MESSAGE_CONTROL0(TtsHostMsg_Resume)
IPC_MESSAGE_CONTROL0(TtsHostMsg_Cancel)
// Browser -> Renderer messages.
IPC_MESSAGE_CONTROL1(TtsMsg_SetVoiceList,
std::vector<TtsVoice>)
IPC_MESSAGE_CONTROL1(TtsMsg_DidStartSpeaking,
int /* utterance id */)
IPC_MESSAGE_CONTROL1(TtsMsg_DidFinishSpeaking,
int /* utterance id */)
IPC_MESSAGE_CONTROL1(TtsMsg_DidPauseSpeaking,
int /* utterance id */)
IPC_MESSAGE_CONTROL1(TtsMsg_DidResumeSpeaking,
int /* utterance id */)
IPC_MESSAGE_CONTROL2(TtsMsg_WordBoundary,
int /* utterance id */,
int /* char index */)
IPC_MESSAGE_CONTROL2(TtsMsg_SentenceBoundary,
int /* utterance id */,
int /* char index */)
IPC_MESSAGE_CONTROL2(TtsMsg_MarkerEvent,
int /* utterance id */,
int /* char index */)
IPC_MESSAGE_CONTROL1(TtsMsg_WasInterrupted,
int /* utterance id */)
IPC_MESSAGE_CONTROL1(TtsMsg_WasCancelled,
int /* utterance id */)
IPC_MESSAGE_CONTROL2(TtsMsg_SpeakingErrorOccurred,
int /* utterance id */,
std::string /* error message */)

View file

@ -0,0 +1,30 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/tts_utterance_request.h"
TtsUtteranceRequest::TtsUtteranceRequest()
: id(0),
volume(1.0),
rate(1.0),
pitch(1.0) {
}
TtsUtteranceRequest::~TtsUtteranceRequest() {
}
TtsVoice::TtsVoice()
: local_service(true),
is_default(false) {
}
TtsVoice::~TtsVoice() {
}
TtsUtteranceResponse::TtsUtteranceResponse()
: id(0) {
}
TtsUtteranceResponse::~TtsUtteranceResponse() {
}

View file

@ -0,0 +1,44 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_COMMON_TTS_UTTERANCE_REQUEST_H_
#define CHROME_COMMON_TTS_UTTERANCE_REQUEST_H_
#include <vector>
#include "base/basictypes.h"
#include "base/strings/string16.h"
struct TtsUtteranceRequest {
TtsUtteranceRequest();
~TtsUtteranceRequest();
int id;
std::string text;
std::string lang;
std::string voice;
float volume;
float rate;
float pitch;
};
struct TtsVoice {
TtsVoice();
~TtsVoice();
std::string voice_uri;
std::string name;
std::string lang;
bool local_service;
bool is_default;
};
struct TtsUtteranceResponse {
TtsUtteranceResponse();
~TtsUtteranceResponse();
int id;
};
#endif // CHROME_COMMON_TTS_UTTERANCE_REQUEST_H_