/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/NavitSpeech.java
ZANavi

Contents of /navit/navit/android/src/com/zoffcc/applications/zanavi/NavitSpeech.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (12 years, 5 months ago) by zoff99
File size: 2776 byte(s)
import files
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * Navit, a modular navigation system.
22 * Copyright (C) 2005-2008 Navit Team
23 *
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * version 2 as published by the Free Software Foundation.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the
35 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 * Boston, MA 02110-1301, USA.
37 */
38
39 package com.zoffcc.applications.zanavi;
40
41 import android.util.Log;
42
43 import com.google.tts.TTS;
44
45 // old crappy TTS, no longer used!!
46 public class NavitSpeech implements Runnable
47 {
48 private static TTS tts;
49 private TTS.InitListener ttsInitListener;
50 private String what;
51 private Thread thread;
52
53 NavitSpeech(Navit navit)
54 {
55 try
56 {
57 ttsInitListener = new TTS.InitListener()
58 {
59 public void onInit(int version)
60 {
61 }
62 };
63 tts = new TTS(navit, ttsInitListener, true);
64 }
65 catch (Exception e)
66 {
67 tts = null;
68 }
69 try
70 {
71 Log.e("NavitSpeech", "Create with locale=" + java.util.Locale.getDefault().getLanguage());
72 tts.setLanguage(java.util.Locale.getDefault().getLanguage());
73 }
74 catch (Exception e)
75 {
76 e.printStackTrace();
77 }
78 }
79
80 public void run()
81 {
82 try
83 {
84 Log.e("NavitSpeech", "In " + what);
85 tts.speak(what, 0, null);
86 }
87 catch (Exception e)
88 {
89 }
90 }
91
92 public void say(String what)
93 {
94 try
95 {
96 this.what = what;
97 thread = new Thread(this, "speech thread");
98 thread.start();
99 }
100 catch (Exception e)
101 {
102 }
103 }
104
105 public static void stop_me()
106 {
107 Log.e("NavitSpeech", "shutdown");
108 try
109 {
110 tts.shutdown();
111 }
112 catch (Exception e)
113 {
114 // old class, so this will always fire!
115 // e.printStackTrace();
116 }
117 }
118 }

   
Visit the ZANavi Wiki