test.html
2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<head>
<meta charset="utf-8" />
<title>demo</title>
<meta name="Keywords" content="先声科技" />
<meta name="Description" content="" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<!-- <script type="text/javascript" src="json2.js"></script> -->
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="sing/sing.engine.js"></script>
<!-- jsonFormater -->
<script type="text/javascript" src="/lib/jsonFormater/jsonFormater.js"></script>
<link rel="stylesheet" href="/lib/jsonFormater/jsonFormater.css">
</head>
<body>
<div id="eng-txt">There's nothing to worry about as long as you work hard.</div>
<div>分数<span id="score"></span></div>
<br/>
<div><input id="follow" type="submit" value="跟读" class="demo-btn"></div>
<br/>
<br/>
<div id="result"></div>
<div id="SSoundWindowC">
<div id="SSoundWindow"></div>
</div>
</body>
<script>
$(document).ready(function(){
$("#score").html('引擎初始化...');
window.engine = new sing.engine({
swf: {
swfFile: "SSound.swf",
width: "300px",
height: "300px"
},
ssoundEvent: {
swfReady: function() {
window.engine.newEngine();
},
startRecord: function() {
myStartRecord();
},
ready: function() {
$("#score").html('引擎初始化完成');
window.engine.testMicrophone();
},
error: function(code) {
console.log('error:', JSON.stringify(code));
if (code[0].statusCode == 50006)
window.engine.newEngine();
},
stopRecord: function() {
myStopRecord();
},
result: function(t, resultObject) {
myRecordResult(resultObject);
}
}
});
//跟读句子
$("#follow").bind("click", function(){
engine.start($("#eng-txt").text());
return false;
})
//我的录音
$("#play").bind("click", function(){
engine.startReplay();
return false;
})
});
var myStartRecord = function() {
$("#score").html('录音中...');
}
var myStopRecord = function() {
$("#score").html('评分中...');
}
var myRecordResult = function(recordResult) {
console.log(recordResult);
$("#score").html(recordResult.result.overall);
var options = {
singleTab: " ", //单个tab
tabSize: 1, //缩进数量
dom : '#result' //对应容器的css选择器
};
var jf = new JsonFormater(options); //创建对象
jf.doFormat(recordResult); //格式化json
// $("#result").html(recordResult);
}
</script>