From 89cc717e3ccd49d49539b25d7a8554126504b51f Mon Sep 17 00:00:00 2001
From: hdw <496960745@qq.com>
Date: 星期五, 02 十一月 2018 08:53:20 +0800
Subject: [PATCH] 电池配组记录区/县添加

---
 gx_tieta/WebRoot/js/VoiceUtil.js |   27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/gx_tieta/WebRoot/js/VoiceUtil.js b/gx_tieta/WebRoot/js/VoiceUtil.js
index cfc0f6a..6bf489e 100644
--- a/gx_tieta/WebRoot/js/VoiceUtil.js
+++ b/gx_tieta/WebRoot/js/VoiceUtil.js
@@ -1,11 +1,12 @@
 // 璁剧疆璇煶鎾姤瀵硅薄
 var Voice = function() {
 	this.speak = window.speechSynthesis;
+	this.tospeak = new SpeechSynthesisUtterance('');
 	this.voice = '';
 	this.zh_CN = false;
 	this.rate = 1.5; 
 	this._setLang();			// 鑾峰彇骞舵娴嬫槸鍚︽湁涓枃鐨勭幆澧�
-	this.timeInterval = 28;		//寰幆闂撮殧(绉�)
+	this.timeInterval = 27;		//寰幆闂撮殧(绉�)
 	this.speak_enable = true;			//ture:寮�鍚闊虫挱鎶�         false:鍋滄璇煶鎾姤
 };
 
@@ -15,7 +16,7 @@
 		console.info('浣犵殑鐢佃剳涓嶆敮鎸佷腑鏂囨挱鎶ワ紒');		
 	}
 	_timeInterval = this.timeInterval;
-	//console.info(this.zh_CN);
+	//console.info(this.speak_enable);
 	if(!this.speak_enable){									//璇嗗埆鏄惁寮�鍚0闊虫挱鎶�
 		if(callback && typeof callback == 'function'){
 			setTimeout(function(){
@@ -25,19 +26,19 @@
 		return;
 	}
 	this.cancel();
-	var to_speak = new SpeechSynthesisUtterance(txt);
-	to_speak.voice = this.voice;	// 璁惧畾涓枃鎾姤
-	to_speak.rate = this.rate;
-	console.info(to_speak);
-	this.speak.speak(to_speak);
-	
+	this.tospeak.text = txt;
+	this.tospeak.voice = this.voice;	// 璁惧畾涓枃鎾姤
+	this.tospeak.rate = this.rate;
+	//console.info(to_speak);
 	var starttime = new Date();
-	to_speak.onend = function(event) {	
-		//console.info(event);
+	this.speak.speak(this.tospeak);
+	//console.info(this.tospeak);
+	this.tospeak.onend = function(event) {	
+		//console.info("鎾斁缁撴潫");
 		if(callback && typeof callback == 'function'){
 			var endtime = new Date();
 			var timelong = (endtime.getTime()-starttime.getTime())/1000;
-			console.info(parseInt(_timeInterval)+"==="+parseInt(timelong));
+			//console.info(parseInt(_timeInterval)+"==="+parseInt(timelong));
 			if(timelong > this.timeInterval){				
 				callback();
 			}else{
@@ -48,9 +49,7 @@
 		}
 	};
 	
-	to_speak.onerror = function(event) {	
-		//console.info(event);
-	};
+
 };
 
 // 閫�鍑哄綋鍓嶆挱鎶�

--
Gitblit v1.9.1