前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【开源公告】微信智聆口语评测小程序开源

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

作者头像
腾讯开源
修改2019-05-16 16:10:28
3.8K0
修改2019-05-16 16:10:28
举报

由微信智聆语音团队研发的智聆口语评测小程序插件,能够对学习者的发音进行自动评测打分,检测发音中存在的错误。评测人群支持从儿童到成人年龄全覆盖;评测方式涵盖单词、句子、段落、自由说、情景对话等一系列评测模式。目前以小程序插件的方式开放其中的单词和句子评估两种模式。 现在开源完全基于智聆口语测评插件实现的微信智聆口语评测小程序,以进一步降低小程序开发者使用插件的门槛。  小程序开发者参考微信智聆口语评测开源实现,只需要调用几个简单API,就可以完成一个评测应用。

插件功能

  • 单词评估
  • 句子评估

下面将展示如何使用插件轻松实现口语评测小程序。

添加插件

在使用前,需要登录官网 设置 → 第三方服务 → 添加插件

搜索 【智聆口语评测】并添加

在需要使用插件的小程序 app.json 中指明需要使用的插件版本等信息

代码语言:javascript
复制
// app.json
{
  ...
  "plugins": {
    ...
    "ihearing-eval": {
      "version": "0.0.3",
      "provider": "wx63d6102e26f0a3f8"
  }
}

接下来,在index.js引入插件,获取全局唯一的语音识别管理器recordRecoManager

代码语言:javascript
复制
// index.js
const plugin = requirePlugin("ihearing-eval")
const manager = plugin.getRecordRecognitionManager()

单词评估

单词模式是只针对一个单词的发音评测,评测结果要求更加细致,输出结果可以包括:

  • 音素准确度
  • 单词准确度
  • 流畅度

并且可以标志发音有误的音标

例子如图:

代码语言:javascript
复制
<!-- 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>
绑定开始和结束事件:
代码语言:javascript
复制
// 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()
  }
})
绑定回调事件:
代码语言:javascript
复制
// 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!

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-04-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 腾讯开源 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 绑定开始和结束事件:
  • 绑定回调事件:
相关产品与服务
智聆口语评测
智聆口语评测(Smart Oral Evaluation,SOE)是腾讯云推出的中英文语音评测产品,支持从儿童到成人全年龄覆盖的语音评测,支持单词、句子、段落、自由说等多种模式,支持发音准确度、流利度、完整度等全方位打分机制,与专家打分相似度达95%以上,可广泛应用于中文及英语口语类教学中。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档