当前位置:网站首页>HMS Core机器学习服务实现同声传译,支持中英文互译和多种音色语音播报
HMS Core机器学习服务实现同声传译,支持中英文互译和多种音色语音播报
2022-06-25 17:21:00 【华为移动服务】
当用户有跨语种交流或音频内容翻译的需求时,应用需要能自动检测语音内容再输出为用户需要的语言文字。
HMS Core机器学习服务提供同声传译能力,同声传译实现将实时输入的长语音实时翻译为不同语种的文本以及语音,并实时输出原语音文本、翻译后的文本以及翻译文本的语音播报。
在直播类,会议类的应用中,同声传译显得尤为重要。比如,在会议类应用中,可以将正在进行的会议发言人的发言内容实时输出为目标语言文字,便于不同语言的人实时理解会议内容,提高会议效率。在直播类应用中,可以将主播的说话内容实时输出为用户需要的语言文字,再进行实时播报,提高了用户的观看体验。
HMS Core机器学习服务同声传译能力不仅支持连续5小时的实时长语音输入转换为文本,还支持中英文互译和多种音色语音播报,满足不同类型应用中不同场景的需要。
DEMO示例

开发步骤
在进行开发之前,您需要完成必要的开发准备工作,同时请确保您的工程中已经配置HMS Core SDK的Maven仓地址,并且完成了本服务的SDK集成。
SDK示例代码如下:
dependencies{
// 引入同声传译服务SDK
implementation 'com.huawei.hms:ml-computer-si-sdk:3.5.0.312'
}- 请参见云端鉴权信息使用须知,设置您应用的鉴权信息。
- 创建同传识别器,并设置配置。
MLSimultaneousInterpretationConfig config = new
MLSimultaneousInterpretationConfig.Factory()
// 设置源语种,目前支持中文和英文
.setSourceLanguage(MLSimultaneousInterpretationConstants.LAN_ZH_CN)
// 设置目标语种,目前支持中文和英文
.setTargetLanguage(MLSimultaneousInterpretationConstants.LAN_EN_US)
// 设置识别类型。支持原始文本+翻译文本+翻译语音
.setResultType(MLSimultaneousInterpretationConstants.RESULT_TYPE_TEXT_TRANSLATED_VOICE)
// 设置发音人,支持中、英男声和女声
.setPerson(MLSimultaneousInterpretationConstants.EN_FEMALE_VOICE)
.create();
MLSimultaneousInterpretationRecognizer = MLSimultaneousInterpretationRecognizer.getInstance();- 创建语音识别结果监听器回调。
// 回调实现MLSimultaneousInterpretationListener,实现接口中的方法。
protected class SIRecognitionListener implements MLSimultaneousInterpretationListener {
@Override
public void onStartListening() {
// 录音器开始接收声音。
}
@Override
public void onVoiceDataReceived(byte[] data) {
// 返回给用户原始的PCM音频流和音频能量,该接口并非运行在主线程中,返回结果需要在子线程中处理。
}
@Override
public void onRecognizingResults(Bundle partialResults) {
// 从SIRecognitionListener接收到持续语音识别的文本。
// RESULTS_RECOGNIZING:原始文本;RESULTS_TRANS_RECOGNIZING:tts文本;RESULTS_SN:原始序列号;RESULTS_TRANS_SN:tts序列号
}
@Override
public void onResults(Bundle results) {
// 从SIRecognitionListener接收到完整的句子
// RESULTS_RECOGNIZED:原始结果;RESULTS_TRANS_RECOGNIZED:tts结果
}
@Override
public void onError(int error, String errorMessage) {
// 识别发生错误后调用该接口。
}
@Override
public void onState(int state, Bundle params) {
// 通知应用状态发生改变。
}
}- 绑定同传识别器。
mlSimultaneousInterpretationRecognizer.setMLSimultaneousInterpretationListener(new SIRecognitionListener());- 调用startRecognizing启动语音识别。
// 开始识别。
mlSimultaneousInterpretationRecognizer.startRecognizing(config);- 识别完成后,结束识别并释放资源。
if (mlSimultaneousInterpretationRecognizer!= null) {
mlSimultaneousInterpretationRecognizer.destroy();
}了解更多详情>>
访问华为开发者联盟官网
获取开发指导文档
华为移动服务开源仓库地址:GitHub、Gitee
关注我们,第一时间了解 HMS Core 最新技术资讯~
边栏推荐
- 2021年5月云南省网络空间安全比赛赛题复盘
- jupyter的使用
- Jerry's addition of encrypted file playback function [chapter]
- 汇编语言(5)寄存器(内存访问)
- Sword finger offer II 010 Subarray prefix sum difference with sum K
- How Jerry used to output a clock source to the outside world [chapter]
- cgi通过odbc连接数据库
- [micro service sentinel] overview of flow control rules | detailed explanation of flow control mode for source | < direct link >
- Redis distributed lock collation
- Interrupt operation: abortcontroller learning notes
猜你喜欢

智能对话01-redis的安装

Design and arrangement of DDIA data intensive application system

Learn Tai Chi Maker - mqtt (III) connect to mqtt server

Automatic submission for the next education day

杰理之系统时钟设置出现复位或无效问题【篇】

WARNING: Unsupported upgrade request.

Kotlin

Redis distributed lock collation

【Matlab】数值微积分与方程求解

学习太极创客 — MQTT(三)连接MQTT服务端
随机推荐
数据搬迁最佳实践之使用CDM搬迁线下MySQL到DWS
try with resource
CVPR small target detection: context and attention mechanisms improve small target detection (attached with paper Download)
华为云GaussDB(for Redis)揭秘第19期:GaussDB(for Redis)全面对比Codis
Singleton mode application
启牛的涨乐财付通如何?安全靠谱吗
PSYNC command of redis
[UVM practice== > episode_2] ~ VIP, VIP development, VIP release
【UVM实战 ===> Episode_1 】~ MCDF设计更新、AMBA标准接口、UVM验证环境更新
【UVM实战 ===> Episode_2 】~ VIP、VIP的开发、VIP的发布
golang sort slice int
记一次基于PHP学生管理系统的开发
揭秘GES超大规模图计算引擎HyG:图切分
国泰君安证券靠谱吗?是否合法?开股票账户安全吗?
UART波特率对时钟精度的要求有多高?
有关QueryInterface函数
Sword finger offer II 012 The sum of left and right subarrays is equal
jupyter的使用
超全金属PBR多通道贴图素材网站整理
Kotlin入门(20)几种常见的对话框