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

开发步骤
在进行开发之前,您需要完成必要的开发准备工作,同时请确保您的工程中已经配置HMS Core SDK的Maven仓地址,并且完成了本服务的SDK集成。
SDK示例代码如下:
dependencies{ // 引入同声传译服务SDKimplementation '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 最新技术资讯~
边栏推荐
- JS to verify whether the string is a regular expression
- JS determines whether two values are equal, and compares any two values, including array objects
- 启牛是正规的吗?股票开户安全吗?
- 中国电池技术取得重大突破,日韩美都落后了,中国巩固了领先优势
- Using Sphinx to automatically generate API documents from py source files
- Preventing overfitting of deep neural networks (mysteries of neural networks Part II)
- Tencent cloud builds a Socks5 multi IP proxy server to realize the perfect building of a game with a single window and a single IP. Tutorial attached tool "suggestions collection"
- [world history] Episode 1: people in the Stone Age
- 第一次读 “Clean” 系列,并没有觉得这是一本多好的书
- Shell operator
猜你喜欢

【中國海洋大學】考研初試複試資料分享

China has made major breakthroughs in battery technology. Japan, South Korea and the United States are lagging behind. China has consolidated its leading edge

Add the resources directory under test in idea

分享自己平時使用的socket多客戶端通信的代碼技術點和軟件使用

Installation and removal of MySQL under Windows

Thymeleaf Usage Summary

Test your earning power? What will you do in the future?

Does stream even have application advanced learning? As a programmer, you know what

JVM uses tools to analyze classic cases of OOM

Preventing overfitting of deep neural networks (mysteries of neural networks Part II)
随机推荐
None of the MLIR Optimization Passes are enabled (registered 2)解决办法
About reconnection of STM32 using lan8720a plug-in network cable
还没弄明白微服务数据架构事务管理+ACID+一致性+CAP+BASE理论吗,看完彻底解决疑惑
分享自己平时使用的socket多客户端通信的代码技术点和软件使用
Jaspersoft studio installation
Turtlebot+lms111+gmapping practice
广发易淘金和同花顺哪个更好,更安全一些
重磅!国产 IDE 发布,由阿里研发,完全开源!(高性能+高定制性)
JVM 用工具分析OOM经典案例
As a software testing engineer, how do you think to ensure software quality?
Typescript and go --- essence
Laravel8 implementation of picture verification code
ffmpeg protocol concat 进行ts流合并视频的时间戳计算及其音画同步方式一点浅析
[untitled]
None of the MLIR optimization passes are enabled (registered 2) solutions
Jaspersoft studio adding MySQL database configuration
[untitled]
Settings the PC must be turned on
Partager les points techniques de code et l'utilisation de logiciels pour la communication Multi - clients socket que vous utilisez habituellement
Hash table, hash conflict