Adding the synthesizer/vocalizer part for now.
Will add the recognition later.
<a href="callhistory.html"><div class="block">Call History</div></a>
<a href="mediaserver.html"><div class="block">mediaserver</div></a>
<a href="content.html"><div class="block">content</div></a>
+<a href="speech.html"><div class="block">speech</div></a>
</body>
</html>
--- /dev/null
+<html>
+<head>
+<title>Speech Example</title>
+<script>
+function handleTextToSpeech() {
+ var currentText = document.getElementById("inputText").value;
+ var newText = tizen.speech.VocalizeString(currentText);
+ document.getElementById("inputText").value = newText;
+}
+</script>
+</head>
+<body>
+ <div name="input">
+ <div id="instructionLabel">Type in some text</div>
+ <input type="text" id="inputText"><br>
+ <button id="say" onClick="handleTextToSpeech()">Speak Out</button>
+ </div>
+</body>
+</html>
BuildRequires: pkgconfig(dbus-glib-1)
# Evas.h is required by capi-web-favorites.
BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(tapi)
BuildRequires: pkgconfig(libudev)
--- /dev/null
+{
+ 'includes':[
+ '../common/common.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'tizen_speech',
+ 'type': 'loadable_module',
+ 'variables': {
+ 'packages': [
+ 'gio-2.0',
+ ],
+ },
+ 'includes': [
+ '../common/pkg-config.gypi',
+ ],
+ 'sources': [
+ 'speech_api.js',
+ 'speech_extension.cc',
+ 'speech_extension.h',
+ 'speech_instance.cc',
+ 'speech_instance.h',
+ '../common/extension.cc',
+ '../common/extension.h',
+ ],
+ },
+ ],
+}
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var postMessage = function(msg) {
+ extension.postMessage(JSON.stringify(msg));
+};
+
+var sendSyncMessage = function(msg) {
+ return extension.internal.sendSyncMessage(JSON.stringify(msg));
+};
+
+exports.VocalizeString = function(speakText) {
+ try {
+ var r = JSON.parse(sendSyncMessage({
+ 'cmd': 'VocalizeString',
+ 'text': speakText
+ }));
+ } catch (e) {
+ console.error('Parsing error: ', e);
+ }
+ return r['text'];
+};
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "speech/speech_extension.h"
+
+#include "speech/speech_instance.h"
+
+common::Extension* CreateExtension() {
+ return new SpeechExtension();
+}
+
+// This will be generated from speech_api.js
+extern const char kSource_speech_api[];
+
+SpeechExtension::SpeechExtension() {
+ SetExtensionName("tizen.speech");
+ SetJavaScriptAPI(kSource_speech_api);
+}
+
+SpeechExtension::~SpeechExtension() {}
+
+common::Instance* SpeechExtension::CreateInstance() {
+ return new SpeechInstance;
+}
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SPEECH_SPEECH_EXTENSION_H_
+#define SPEECH_SPEECH_EXTENSION_H_
+
+#include "common/extension.h"
+
+class SpeechExtension : public common::Extension {
+ public:
+ SpeechExtension();
+ virtual ~SpeechExtension();
+
+ private:
+ // common::Extension implementation
+ virtual common::Instance* CreateInstance();
+};
+
+#endif // SPEECH_SPEECH_EXTENSION_H_
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "speech/speech_instance.h"
+
+#include <gio/gio.h>
+#include <string>
+
+SpeechInstance::SpeechInstance() {}
+
+SpeechInstance::~SpeechInstance() {}
+
+void SpeechInstance::HandleMessage(const char* message) {}
+
+void SpeechInstance::HandleSyncMessage(const char* message) {
+ picojson::value v;
+ std::string err;
+ picojson::parse(v, message, message + strlen(message), &err);
+ if (!err.empty())
+ return;
+
+ picojson::value::object o;
+ std::string cmd = v.get("cmd").to_str();
+ if (cmd == "VocalizeString")
+ o = HandleVocalizeString(v);
+
+ SendSyncReply(picojson::value(o).serialize().c_str());
+}
+
+const picojson::value::object SpeechInstance::HandleVocalizeString(
+ const picojson::value& msg) {
+ picojson::value::object o;
+
+ std::string speakText = msg.get("text").to_str();
+ g_dbus_connection_call(g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL),
+ "org.tizen.srs",
+ "/tts",
+ "org.tizen.srs",
+ "synthesize",
+ g_variant_new("(ss)", speakText.c_str(), "english"),
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ NULL,
+ NULL);
+
+ o["text"] = picojson::value("");
+ return o;
+}
--- /dev/null
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SPEECH_SPEECH_INSTANCE_H_
+#define SPEECH_SPEECH_INSTANCE_H_
+
+#include "common/extension.h"
+#include "common/picojson.h"
+
+class SpeechInstance : public common::Instance {
+ public:
+ SpeechInstance();
+ virtual ~SpeechInstance();
+
+ private:
+ // common::Instance implementation.
+ virtual void HandleMessage(const char* msg);
+ virtual void HandleSyncMessage(const char* message);
+
+ const picojson::value::object
+ HandleVocalizeString(const picojson::value& msg);
+};
+
+#endif // SPEECH_SPEECH_INSTANCE_H_
'network_bearer_selection/network_bearer_selection.gyp:*',
'notification/notification.gyp:*',
'power/power.gyp:*',
+ 'speech/speech.gyp:*',
'system_info/system_info.gyp:*',
'system_setting/system_setting.gyp:*',
'time/time.gyp:*',