| | |
| | | |
| | | void SetDummyLightExam(int n, struct dummy_light_exam *cfg) |
| | | { |
| | | DEBUG("获取模拟路考灯光测试项目"); |
| | | |
| | | if (TestStart) return; |
| | | |
| | | if (DummyLightContent != NULL) { |
| | |
| | | void StartDriverExam(int start, int type) |
| | | { |
| | | bool err = false; |
| | | DEBUG("++++++++++++考试启动 start %d type %d+++++++++++++", start, type); |
| | | |
| | | if (start == 0) { |
| | | DEBUG("-------------结束考试----------------"); |
| | | |
| | | // CurrExamMapIndex = -1; |
| | | // TestStart = false; |
| | | // CommTestStart(false); |
| | | // MA_SendExamStatus(0, 0); |
| | | return; |
| | | } |
| | | |
| | | DEBUG("+++++++++++++++开始考试++++++++++++++++++++"); |
| | | |
| | | if (MapNum == 0) { |
| | | err = true; |
| | |
| | | examFaultIndex = 0; |
| | | |
| | | TestStart = true; |
| | | TestType = type; |
| | | CommTestStart(true); |
| | | |
| | | if (type == TEST_TYPE_ROAD_DUMMY_LIGHT) { |
| | |
| | | const Value &s2 = (*itr)["tts"]; |
| | | |
| | | content[n].item = s1.GetInt(); |
| | | strcpy(content[n].tts, s1.GetString()); |
| | | strcpy(content[n].tts, s2.GetString()); |
| | | n++; |
| | | } |
| | | } |
| | |
| | | import com.anyun.exam.lib.util.DESUtil; |
| | | import com.anyun.exam.lib.util.NetUtils; |
| | | import com.anyun.exam.lib.util.Speaker; |
| | | import com.anyun.exam.lib.util.SpeakerCallback; |
| | | |
| | | import androidx.annotation.Nullable; |
| | | |
| | |
| | | public void onCreate() { |
| | | super.onCreate(); |
| | | Log.i(TAG,"onCreate()"); |
| | | speaker = new Speaker(getApplicationContext()); |
| | | speaker = new Speaker(/*getApplicationContext()*/this, new TTSCallback()); |
| | | |
| | | new Thread(new StartNative()).start(); |
| | | |
| | |
| | | } catch (InterruptedException e) { |
| | | |
| | | } |
| | | ttsInitSucc = true; |
| | | } |
| | | } |
| | | |
| | |
| | | return h.toString(); |
| | | } |
| | | |
| | | class TTSCallback implements SpeakerCallback { |
| | | @Override |
| | | public void PlayInit(boolean ret) { |
| | | Log.d(TAG, "TTS引擎初始化成功"); |
| | | ttsInitSucc = ret; |
| | | } |
| | | |
| | | @Override |
| | | public void PlayStart() { |
| | | Log.d(TAG, "TTS引擎播放开始"); |
| | | } |
| | | |
| | | @Override |
| | | public void PlayDone() { |
| | | Log.d(TAG, "TTS引擎播放结束"); |
| | | } |
| | | |
| | | @Override |
| | | public void PlayError() { |
| | | Log.d(TAG, "TTS引擎播放出错"); |
| | | } |
| | | } |
| | | |
| | | // Used to load the 'native-lib' library on application startup. |
| | | static { |
| | | System.loadLibrary("native-lib"); |
| | |
| | | |
| | | import android.content.Context; |
| | | import android.speech.tts.TextToSpeech; |
| | | import android.speech.tts.UtteranceProgressListener; |
| | | import android.util.Log; |
| | | |
| | | import com.anyun.exam.lib.RemoteService; |
| | |
| | | public class Speaker { |
| | | private Context context; |
| | | private TextToSpeech tts; |
| | | private SpeakerCallback callback = null; |
| | | |
| | | final public String TAG = Speaker.class.getCanonicalName(); |
| | | |
| | | public Speaker(final Context context) { |
| | | public Speaker(final Context context, final SpeakerCallback cb) { |
| | | // TODO Auto-generated constructor stub |
| | | Log.d(TAG, "Speaker Init..."); |
| | | this.context = context; |
| | | this.callback = cb; |
| | | |
| | | tts = new TextToSpeech(context, new TextToSpeech.OnInitListener() { |
| | | @Override |
| | | public void onInit(int status) { |
| | |
| | | { |
| | | Log.d(TAG, "TextToSpeech.LANG_NOT_SUPPORTED"); |
| | | } |
| | | if (callback != null) { |
| | | callback.PlayInit(true); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | tts.setOnUtteranceProgressListener(new UtteranceProgressListener() { |
| | | @Override |
| | | public void onStart(String s) { |
| | | if (callback != null) { |
| | | callback.PlayStart(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onDone(String s) { |
| | | if (callback != null) { |
| | | callback.PlayDone(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(String s) { |
| | | if (callback != null) { |
| | | callback.PlayError(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public void speak(String text) { |
| | | Log.d(TAG, "SPEAK"); |
| | | // tts.speak(text, TextToSpeech.QUEUE_FLUSH, null); |
| | | tts.speak(text, TextToSpeech.QUEUE_ADD, null, "speech"); |
| | | } |
New file |
| | |
| | | package com.anyun.exam.lib.util; |
| | | |
| | | public interface SpeakerCallback { |
| | | void PlayInit(boolean ret); |
| | | void PlayStart(); |
| | | void PlayDone(); |
| | | void PlayError(); |
| | | } |