Add:Core:New speech module iphone
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 3 May 2012 17:35:08 +0000 (17:35 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 3 May 2012 17:35:08 +0000 (17:35 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@5066 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/CMakeLists.txt
navit/navit/speech/iphone/CMakeLists.txt [new file with mode: 0644]
navit/navit/speech/iphone/VSSpeechSynthesizer.h [new file with mode: 0644]
navit/navit/speech/iphone/speech_iphone.m [new file with mode: 0644]
navit/navit/xslt/iphone.xslt

index 4391546..f59be7d 100755 (executable)
@@ -350,6 +350,7 @@ add_module(map/csv "Default" TRUE)
 add_module(plugin/pedestrian "Default" FALSE)
 add_module(speech/android "Default" FALSE)
 add_module(speech/espeak "Default" FALSE)
+add_module(speech/iphone "Default" FALSE)
 add_plugin(support/espeak "Default" FALSE)
 add_module(vehicle/android "Default" FALSE)
 add_module(vehicle/iphone "Default" FALSE)
@@ -477,6 +478,7 @@ endif()
 if (APPLE OR USE_UIKIT)
    set_with_reason(vehicle/iphone "apple detected" TRUE)
    set_with_reason(graphics/cocoa "apple detected" TRUE)
+   set_with_reason(speech/iphone "apple detected" TRUE)
    set(BUILD_BUNDLE TRUE CACHE BOOLEAN "build an osx bundle")
 endif()
 
diff --git a/navit/navit/speech/iphone/CMakeLists.txt b/navit/navit/speech/iphone/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fff10ff
--- /dev/null
@@ -0,0 +1 @@
+module_add_library(speech_iphone speech_iphone.m)
diff --git a/navit/navit/speech/iphone/VSSpeechSynthesizer.h b/navit/navit/speech/iphone/VSSpeechSynthesizer.h
new file mode 100644 (file)
index 0000000..d7b83e3
--- /dev/null
@@ -0,0 +1,18 @@
+#import  <foundation/foundation.h>
+
+@interface VSSpeechSynthesizer : NSObject
+{
+}
+
++ (id)availableLanguageCodes;
++ (BOOL)isSystemSpeaking;
+- (id)startSpeakingString:(id)string;
+- (id)startSpeakingString:(id)string toURL:(id)url;
+- (id)startSpeakingString:(id)string toURL:(id)url withLanguageCode:(id)code;
+- (float)rate;             // default rate: 1
+- (id)setRate:(float)rate;
+- (float)pitch;           // default pitch: 0.5
+- (id)setPitch:(float)pitch;
+- (float)volume;       // default volume: 0.8
+- (id)setVolume:(float)volume;
+@end
diff --git a/navit/navit/speech/iphone/speech_iphone.m b/navit/navit/speech/iphone/speech_iphone.m
new file mode 100644 (file)
index 0000000..7b443ab
--- /dev/null
@@ -0,0 +1,74 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+#include "config.h"
+#include "item.h"
+#include "debug.h"
+#include "plugin.h"
+#include "speech.h"
+#import "VSSpeechSynthesizer.h"
+
+struct speech_priv {
+       VSSpeechSynthesizer *speech;
+};
+
+static int 
+speech_iphone_say(struct speech_priv *this, const char *text)
+{
+#if 0
+       NSString *s=[[NSString alloc]initWithCString:text encoding:NSMacOSRomanStringEncoding];
+#else
+       NSString *s=[NSString stringWithUTF8String: text];
+#endif
+       [this->speech startSpeakingString:s];
+       [s release];
+       return 1;
+}
+
+static void 
+speech_iphone_destroy(struct speech_priv *this)
+{
+       [this->speech release];
+       g_free(this);
+}
+
+static struct speech_methods speech_iphone_meth = {
+       speech_iphone_destroy,
+       speech_iphone_say,
+};
+
+static struct speech_priv *
+speech_iphone_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent)
+{
+       struct speech_priv *this;
+       *meth=speech_iphone_meth;
+       this=g_new0(struct speech_priv,1);
+       this->speech=[[NSClassFromString(@"VSSpeechSynthesizer") alloc] init];
+       [this->speech setRate:(float)1.0];
+       return this;
+}
+
+
+void
+plugin_init(void)
+{
+       plugin_register_speech_type("iphone", speech_iphone_new);
+}
index e513a33..1b04622 100644 (file)
       <xsl:attribute name="follow">1</xsl:attribute>
       <xsl:apply-templates/></xsl:copy>
    </xsl:template>
+   <xsl:template match="/config/navit/speech">
+      <xsl:copy>
+         <xsl:copy-of select="@*[not(name()='data')]"/>
+         <xsl:attribute name="type">iphone</xsl:attribute>
+         <xsl:apply-templates/>
+      </xsl:copy>
+   </xsl:template>
    <xsl:template match="/config/navit/mapset/xi:include">
       <map type="binfile" enabled="yes" data="/var/mobile/navit/navitmap.bin" />
       <map type="binfile" enabled="yes" data="../Documents/navitmap.bin" />