我尝试在我的网站上将此文字用作语音。
https://www.youtube.com/watch?v=DOtkNxmg9QY
当我单击nanogallery2中的播放(自定义1)按钮时,我希望此文字朗读。
此带有哈巴狗的纳米画廊代码(home.pug)
script(type='text/javascript'src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js')
link(href='https://unpkg.com/nanogallery2/dist/css/nanogallery2.min.css' rel='stylesheet' type='text/css')
script(type='text/javascript' src='https://unpkg.com/nanogallery2/dist/jquery.nanogallery2.min.js')
#my_nanogallery2(data-nanogallery2=
{
"items": categ,
"itemsBaseURL": "/users/",
"locationHash": false,
"thumbnailWidth": "250",
"thumbnailHeight": "250",
"thumbnailBorderVertical": 4,
"thumbnailBorderHorizontal": 4,
"colorScheme":
{
"thumbnail":
{
"background": 'rgba(97, 152, 253, 1)',
"thumbnailIcon" : { "color": '#FFF'}
}
},
"thumbnailLabel":
{
"position": "onBottom",
"titleFontSize": '1.5em'
},
"thumbnailAlignment": "center",
"thumbnailDisplayTransitionDuration": 0,
"thumbnailDisplayInterval": 3,
"thumbnailHoverEffect2": null,
"thumbnailToolbarImage": { topLeft: 'custom1'},
"thumbnailToolbarAlbum": { topLeft: 'custom1'},
"icons": { thumbnailCustomTool1 : '<i class="fa fa-play-circle" style="font-size:24px"></i>'},
"fnThumbnailToolCustAction": SoundCustom,
"thumbnailOpenImage": false })
此选项向我的纳诺画廊添加了一个按钮,当我单击该按钮时,“ soundcustom”功能应该可以使用。
"thumbnailToolbarImage": { topLeft: 'custom1'},
"thumbnailToolbarAlbum": { topLeft: 'custom1'},
"icons": { thumbnailCustomTool1 : '<i class="fa fa-play-circle" style="font-size:24px"></i>'},
"fnThumbnailToolCustAction": SoundCustom,
这是home.js中的功能“ soundcustom”
function SoundCustom(item){
console.log(item.title);
var text;
text = encodeURIComponent(item.title);
console.log(text);
var url = "http://translate.google.com/translate_tts?tl=en&q=" + text + "&client=tw-ob";
$('audio').attr('src', url).get(0).play();
}
我正在尝试放入控制台日志以查看是否获得了该值。但是事实证明我什么也没得到。
当然也不会对按下按钮有反应。
此外,当我尝试添加他们在视频中提供的脚本时,它会破坏纳米画廊。
我不知道是否相关。
谢谢
经过多次尝试..失败是将值输入到纳米画廊。
“ fnThumbnailToolCustAction”:SoundCustom,
收件人:
“ fnThumbnailToolCustAction”:“ SoundCustom”,
希望其他人不要落在它上面。 👍