由微信智聆語音團隊研發的智聆口語評測小程式插件,能夠對學習者的發音進行自動評測打分,檢測發音中存在的錯誤。評測人群支援從兒童到成人年齡全覆寫;評測方式涵蓋單詞、句子、段落、自由說、情景對話等一系列評測模式。目前以小程式插件的方式開放其中的單詞和句子評估兩種模式。
現在開源完全基于智聆口語測評插件實作的微信智聆口語評測小程式,以進一步降低小程式開發者使用插件的門檻。
小程式開發者參考微信智聆口語評測開源實作,隻需要調用幾個簡單API,就可以完成一個評測應用。
插件功能
- 單詞評估
- 句子評估
下面将展示如何使用插件輕松實作口語評測小程式。
添加插件
在使用前,需要登入官網 設定 → 第三方服務 → 添加插件
搜尋 【智聆口語評測】并添加
在需要使用插件的小程式 app.json 中指明需要使用的插件版本等資訊
// app.json
{
...
"plugins": {
...
"ihearing-eval": {
"version": "0.0.3",
"provider": "wx63d6102e26f0a3f8"
}
}
複制
接下來,在index.js引入插件,擷取全局唯一的語音識别管理器recordRecoManager
// index.js
const plugin = requirePlugin("ihearing-eval")
const manager = plugin.getRecordRecognitionManager()
複制
單詞評估
單詞模式是隻針對一個單詞的發音評測,評測結果要求更加細緻,輸出結果可以包括:
- 音素準确度
- 單詞準确度
- 流暢度
并且可以标志發音有誤的音标
例子如圖:

<!-- index.wxml -->
<view class="container">
<view class="panel">
<view class="assessment-wrap">
<text class="assessment-item">{{assessmentItem.content}}</text>
<text class="phonetic" wx:if="{{ !hasResult }}">/{{assessmentItem.phonetic}}/</text>
<text class="phonetic" wx:if="{{ hasResult }}">
<text>/</text>
<text wx:for="{{phoneticArr}}" wx:key="phone" class="text-{{item.type}}">{{item.phone}}</text>
<text>/</text>
</text>
</view>
</view>
<view class="result-bg result" wx:if="{{hasResult}}">
<view class="source">{{overallResult.pron_accuracy}}</view>
<view class="result-pron">
<view class="pron-item" wx:for="{{overallIndex}}" wx:key="key">
<text class="pron-label">{{item.desc}}</text>
<progress class="pron-progress" percent="{{overallResult[item.key]}}" />
<text class="pron-val">{{overallResult[item.key]}}%</text>
</view>
</view>
</view>
<view class="bottom">
<view class="btn-speak" catchtouchstart="streamRecord" catchtouchend="endStreamRecord">按住跟讀</view>
</view>
</view>
複制
綁定開始和結束事件:
// index.js
const overallIndex = [{
key: 'pron_accuracy',
desc: '準确度',
},
{
key: 'pron_fluency',
desc: '流暢度',
},
{
key: 'pron_completion',
desc: '完成度',
},
]
Page({
data: {
assessmentItem:{"content": "friend", "phonetic": "fr\u025bnd"}
hasResult: false, // 整體結果
overallResult: {}, // 整體名額
overallIndex: overallIndex, // 傳回結果處理後的音标數組
phoneticArr: [ ],
},
streamRecord: function() {
manager.start({
content: this.data.assessmentItem.content,
evalMode: 'word',
scoreCoeff: 1.0,
})
},
streamRecordEnd: function() {
manager.stop()
}
})
複制
綁定回調事件:
// index.js
Page({
data: {},
// 單詞模式處理音标
handlePhoneInfo: function(result) {
let word = result.words[0]
let phoneArr = word.phone_info
let phoneHandledArr = []
for(let i = 0; i < phoneArr.length; i++) {
let phoneItem = phoneArr[i]
let phoneType = this.getAccuracyType(phoneItem.pron_accuracy)
phoneHandledArr.push({
phone: phoneItem.phone,
type: phoneType,
})
}
this.setData({
phoneticArr: phoneHandledArr
})
},
// 統一處理整體評估結果
handleOverallResult: function(result) {
this.setData({
overallResult: {
pron_accuracy: this.handleNum(result.pron_accuracy),
pron_fluency: this.handleNum(result.pron_fluency),
pron_completion: this.handleNum(result.pron_completion),
},
})
},
// 單詞模式
buildWordResult: function(result) {
this.handleOverallResult(result)
this.handlePhoneInfo(result)
},
initRecord: function() {
// 識别結束事件
manager.onStop = (res) => {
console.log("out stop", res)
let result = res.result
// 識别内容為空
if(result.words.length == 0) {
this.showRecordEmptyTip()
return
}
// 處理單詞結果
this.buildWordResult(result)
this.setData({
hasResult: true,
})
wx.hideLoading()
}
// 識别錯誤事件
manager.onError = (res) => {
console.log("out error", res)
}
},
onLoad: function() {
this.initRecord()
}
})
複制
句子評估
句子模式是針對一句話的發音評估,評測結果更側重與整體效果,輸出結果包括:
- 單詞準确度
- 句子完整度
- 流暢度資訊
還可以對句子的單詞做一些統計處理
例子如圖:
更多細節可參考開源代碼以及插件開發文檔。
Github開源位址:
https://github.com/Tencent/iHearing
(點選文末閱讀原文直接通路)
請給 iHearing 一個 Star !
歡迎提出你的 issue 和 PR!