extjs - 在 Extjs 中获取音频和发音 word - word to Speech
问题描述
如何实现单词到语音?
假设我有一个文本字段和一个按钮。我想在用英语发音的文本字段中输入单词。
另外,是否可以只从 Merriam-Webster 在线词典 www.merriam-webster.com/dictionary/stack中获取音频发音并在不打开页面的情况下播放?
或者,也许来自朗文在线发音词典https://www.ldoceonline.com/dictionary/overflow?
我注意到字典中单词的路径具有恒定的模式 - https://www.merriam-webster.com/dictionary/ + 单词,如屏幕截图中所示。
所以,我的问题是:是否可以只提取音频文件(.mp3)并在不打开页面的情况下播放它?
Ext.application({
name: 'Fiddle',
launch: function() {
Ext.create({
xtype: 'panel',
renderTo: Ext.getBody(),
width: 300,
items: [
{
xtype: 'textfield',
name: 'word',
fieldLabel: 'Word',
},{
xtype: 'button',
text: 'Pronounce',
listeners: {
click: function() {
//PRONOUNCE THE WORD
// ...
// ...;
}
}
}]
});
}
});
解决方案
在 html 中包括以下内容:
<script src='https://code.responsivevoice.org/responsivevoice.js'></script>
小提琴代码如下:
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create({
xtype: 'panel',
renderTo: Ext.getBody(),
width: 300,
items: [{
xtype: 'textfield',
name: 'word',
fieldLabel: 'Word',
}, {
xtype: 'button',
text: 'Pronounce',
listeners: {
click: function () {
const speechText = this.previousNode().getValue();
if(speechText) {
responsiveVoice.speak(speechText);
}
}
}
}]
});
}
});
}
});
推荐阅读
- javascript - 直接引用参数属性js
- json - 使用没有 JSON 元数据的 youtube-dl 下载
- r - 如何使用 naivebayes 模型在 R 中运行 locv?
- rust - 为什么直接传递函数时会出现“类型不匹配”错误,但它与等效闭包一起使用?
- flutter - 返回提供程序在 Main.dart 页面上引发错误
- python - VSCode 没有选择正确的 python 解释器
- javascript - ReferenceError:导航器未在 NextJS 和 Framer 上定义
- python - erfinv 函数不适用于数据框 - pyspark
- jax-rs - 可以接收 MULTIPART_FORM_DATA 的 Java 类型是什么?
- go - vscode Go 扩展未显示有用的智能感知完成