当前位置:网站首页>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 最新技术资讯~
边栏推荐
- Realization of neural networks with numpy
- [Ocean University of China] Data Sharing for retest of initial Examination
- Typescript and go --- essence
- Settings the PC must be turned on
- Kubernetes 理解kubectl/调试
- What is the difference between escape, encodeuri and encodeuricomponent?
- Reading the "clean" series for the first time, I didn't think it was a good book
- JS recursion and while
- Logistic Regression VS Linear Regression
- 英語中的九大詞性與九大時態
猜你喜欢

"Mobile cloud Cup" computing power network application innovation competition is in hot registration!

Complete and detailed compilation of experimental reports

What are the red lines of open source that should not be trodden on?

Kubernetes cluster construction of multiple ECS

K-line diagram 24 classic diagrams (shadow)

How does hash eagle, the founder of equity NFT, redefine NFT and use equity to enable long-term value?

分类器与cross entropy loss函数

Today in history: Netease was founded; The first consumer electronics exhibition was held; The first webcast in the world

Suanli & NFT trading platform f3 The exclusive NFT project of XYZ, hash eagle, will be grandly launched

shell 变量 入门
随机推荐
Two methods to rollback the code in pycharm to the specified version (with screenshot)
Thymeleaf Usage Summary
Extend JS copy content to clipboard
Jaspersoft studio adding MySQL database configuration
Discriminative v.s.Generative
Heavyweight! The domestic IDE is released and developed by Alibaba. It is completely open source! (high performance + high customization)
网上股票开户安不安全?有谁知道呢
Shell operator
Shell built-in commands
程序員為什麼要軟一點?
'NVIDIA SMI' is not an internal or external command, nor is it a runnable program or batch file
Complete and detailed compilation of experimental reports
Summary of common functions in Oracle Database
Is qiniu regular? Is it safe to open a stock account?
PubSub JS library realizes "cross component" data transfer
shell 变量 入门
【深度学习】多任务学习 多个数据集 数据集漏标
112页机器学习-数学基础回顾.pptx
Getting started with shell variables
Classifier and cross entropy loss function