前言##
最怕空氣突然安靜,最怕編譯沒(méi)有提示.
對(duì)于非多屏用戶,常常都是按下保存鍵,切回網(wǎng)頁(yè),,等個(gè)幾秒還沒(méi)好,再切回去,心累.
現(xiàn)在你可以給你的編譯加上成功或者失敗的提示音了.
這里可以直接npm run dev感受一下 一個(gè)有聲音的demo
實(shí)現(xiàn)##
其實(shí)就是在webpack編譯事件多加個(gè)插件的事,在這里我用了百度的TTS的API,你也可以直接去download你喜歡的提示音放進(jìn)來(lái)
function AnnouncerPlugin(options) { // customize. } AnnouncerPlugin.prototype.apply = (compiler) => { compiler.plugin('done', () => { getTTS({text:'陳皮爾你是最胖的',spd:6,lan:'zh'},function(f){ var stream = fs.createReadStream(f) var decoder = new lame.Decoder() stream.pipe(decoder).on('format', function(format) { var speaker = new Speaker(format) this.pipe(speaker) }) }) }) } module.exports = AnnouncerPlugin;
然后勒,把他加進(jìn)webpack.config里吧,記得是dev里的...production你會(huì)被人打死
module.exports = { /* other configuration */ plugins: [ /* other configuration */ new WebpackAnnouncerPlugin() ] }
結(jié)尾##
百度的TTS粵語(yǔ)聽(tīng)著賊蠢...不過(guò)人工合成的也就那樣吧
其他沒(méi)啥建議的,想戒掉什么鈴聲就把他換上去吧
--Todo
1.未抽離,用起來(lái)還有點(diǎn)麻煩
2.win下tts的node模塊實(shí)現(xiàn)