微信邦

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4322|回复: 0

【开源公告】微信智聆口语评测小程序开源

[复制链接]
发表于 2019-4-4 17:20:54 | 显示全部楼层 |阅读模式
微信智聆语音团队研发的智聆口语评测小程序插件,能够对学习者的发音进行自动评测打分,检测发音中存在的错误。评测人群支持从儿童到成人年龄全覆盖;评测方式涵盖单词、句子、段落、自由说、情景对话等一系列评测模式。目前以小程序插件的方式开放其中的单词和句子评估两种模式。

现在开源完全基于智聆口语测评插件实现的微信智聆口语评测小程序,以进一步降低小程序开发者使用插件的门槛。

小程序开发者参考微信智聆口语评测开源实现,只需要调用几个简单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

      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()
  }
})



句子评估

句子模式是针对一句话的发音评估,评测结果更侧重与整体效果,输出结果包括:
  • 单词准确度
  • 句子完整度
  • 流畅度信息


还可以对句子的单词做一些统计处理

例子如图:

【开源公告】微信智聆口语评测小程序开源

【开源公告】微信智聆口语评测小程序开源

更多细节可参考开源代码以及插件开发文档。



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

微信邦网联系QQ|Archiver|手机版|小黑屋|鲁公网安备 37082802000167号|微信邦 ( 鲁ICP备19043418号-5 )

GMT+8, 2024-9-19 09:49 , Processed in 0.092106 second(s), 25 queries .

Powered by Discuz! X3.4

© 2001-2013 Wxuse Inc. | Style by ytl QQ:1400069288

快速回复 返回顶部 返回列表