瀏覽代碼

更新;

scbc.sat2 5 年之前
父節點
當前提交
bc2a2dbc58
共有 3 個文件被更改,包括 18 次插入15 次删除
  1. 6 6
      ssat_sdk/UATree/UAT_runnerCommand.py
  2. 1 1
      ssat_sdk/sound/audio_analysis.py
  3. 11 8
      ssat_sdk/sound_tool.py

+ 6 - 6
ssat_sdk/UATree/UAT_runnerCommand.py

@@ -214,7 +214,7 @@ class UATRunnerCommand():
                     elif optionIndex != "":
                         # index属性无法用于判断option,如果在以index属性作为判断依据的页面,则直接返回在这个页面
                         info(self.cls, "checkParentChoose",
-                             "已找到目标parent %s,该页面为Index item页面,无法判断具体option", INFO)
+                             "已找到目标parent %s,该页面为Index item页面,无法判断具体option"%parent['name'], INFO)
                         return 1
                     else:
                         error(self.cls, "checkParentChoose", "当前参数不足以判断option %s是否存在"%(option['name']), ERROR)
@@ -559,7 +559,7 @@ class UATRunnerCommand():
     用于处理parent可能出现的弹窗,isForword用于判断是处理进入弹窗还是退出弹窗
     '''
     def executeDialog(self, parent, isForward=True):
-        print "parent %s executeDialog parent[UATTree.TAB_UI_VIEW]:%s"%(parent, parent[UATTree.TAB_UI_VIEW])
+        print "parent %s executeDialog parent[UATTree.TAB_UI_VIEW]:%s"%(parent[UATTree.TAB_NAME], parent[UATTree.TAB_UI_VIEW])
         if isForward is True:
             dialog_A = parent[UATTree.TAB_UI_VIEW][UATTree.UIView_Dialog_F]
             type = "forward"
@@ -726,17 +726,17 @@ class UATRunnerCommand():
     顺着传入的parent path,逐个确认当前页面是否为该parent。如果不是该parent,则往path后面继续遍历;如果是该parent,则执行该层parent的toParentKey
     '''
     def exitMenuByPath(self, path):
-        print "exitMenuByPath path:", path
+        # print "exitMenuByPath path:", path
         for i in range(0, path.__len__()):
             parent = path[i]
-            info(self.cls, "exitMenuByPath", "check parent:%s"%parent, INFO)
+            info(self.cls, "exitMenuByPath", "check parent:%s"%parent[UATTree.TAB_NAME], INFO)
             ret = self.checkParentChoose(parent)
             if ret < 1:
                 continue
             toParentKey = parent[UATTree.TAB_TOPARENT_KEY]
-            info(self.cls, "exitMenuByPath", "now is in parent:%s"%parent, INFO)
+            info(self.cls, "exitMenuByPath", "now is in parent:%s"%parent[UATTree.TAB_NAME], INFO)
             if toParentKey[UATTree.Key_Event] == [] and toParentKey[UATTree.Key_IR] == []:
-                info(self.cls, "exitMenuByPath", "parent:%s has no toparent_key, using default back" % parent, INFO)
+                info(self.cls, "exitMenuByPath", "parent:%s has no toparent_key, using default back" % parent[UATTree.TAB_NAME], INFO)
                 self.executeKeyByType("back", UATTree.Key_Event)
             else:
                 self.executeKey(toParentKey)

+ 1 - 1
ssat_sdk/sound/audio_analysis.py

@@ -18,7 +18,7 @@ TH_PLOSIVE_TIME = 0.1 #短于0.1秒的声音,判断为爆破音,大于0.1秒
 TH_BLOCK_TIME = 0.1#声音间断间隔时间,单位s
 
 class AAnalysis():
-
+    TH_POWER = getSoundLevel()  # 平均短时能有无声的阈值
     def __init__(self):
         self.varList = [] #记录各声道有无声变化
         self.nChannels = 2

+ 11 - 8
ssat_sdk/sound_tool.py

@@ -209,6 +209,7 @@ class AudioIdentify():
             retExpList = self.changeMonSoundResult(ExpList)
             # print u'monitorSound end',retExpList
             MuTex.release()  # 解锁
+            print "monitorSound end:", seconds, retExpList
             return retExpList
         elif self.deviceType == 1:
             # 采集时长,单位毫秒;
@@ -232,10 +233,12 @@ class AudioIdentify():
         thread.start_new_thread(self.monitorSound, (seconds, expList, waveFile, buf_time,))
 
     def changeMonSoundResult(self,ExpList):
-        # print "changeMonSoundResult:",self.aAnalysis.hasSound,self.aAnalysis.hasBlock,self.aAnalysis.hasPlosive
         self.isSound = self.aAnalysis.hasSound
         self.hasBlock = self.aAnalysis.hasBlock
-        self.getSoundPower()
+        soundPower = self.getSoundPower()
+        print "changeMonSoundResult:", self.aAnalysis.hasSound, self.aAnalysis.hasBlock, self.aAnalysis.hasPlosive,soundPower
+        if soundPower - self.aAnalysis.TH_POWER >= 0:
+            self.aAnalysis.hasSound = True
         if self.aAnalysis.hasSound is True and self.aAnalysis.hasBlock is True:
             ExpList[0]["status"] = self.Sound_Break
         elif self.aAnalysis.hasSound is True and self.aAnalysis.hasBlock is False:
@@ -294,10 +297,10 @@ class AudioIdentify():
 
 if __name__ == "__main__":
     aIden = AudioIdentify()
-
-    sound1 = "D:/1.wav"
-    sound2 = "D:/2.wav"
-    list1=[]
+    aIden.monitorSound(5)
+    # sound1 = "D:/1.wav"
+    # sound2 = "D:/2.wav"
+    # list1=[]
     # expList1 = aIden.monitorSoundTH(10)
     # time.sleep(15)
     # aIden.recordAudioFileReturnPath(5, "wavetest_%s.wav" % str(1))
@@ -311,8 +314,8 @@ if __name__ == "__main__":
     #     time.sleep(3)
     # print "getSoundPower:",aIden.getSoundPower(LR=True)
     # print "getTotalAVGPower:",aIden.aAnalysis.getTotalAVGPower(LR=True)
-    aIden.aAnalysis.analyWav("D:/5.wav")
-    print "getLRVariation:",aIden.getLRVariation()
+    # aIden.aAnalysis.analyWav("D:/5.wav")
+    # print "getLRVariation:",aIden.getLRVariation()
     # print "getFFTPower:",aIden.aAnalysis.getFFTPower(LR=True)
     # print "aIden.isOK():", aIden.isOK(),list1
     # shutil.move(expList1[0]['audio'], sound1)