mqycn / huile8

英语差等生必备的 vscode 插件,解决 单词不会读、单词不认识的痛点

Home Page:https://marketplace.visualstudio.com/items?itemName=mqycn.huile8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

能否采用有道词典发音更换现有发音方式

zzzmj opened this issue · comments

commented

经过阅读作者源码,发现发音方式是通过SpeechSynthesisUtterance合成发音的。

有没有可能使用一些词典的API来发音呢?这样发音会更好听一些

例如有道的API:http://dict.youdao.com/dictvoice?type=0&audio=analogue

例如下列方式

<h1>请点击标签切换到代码页</h1>
<video id="video" controls="" autoplay name="media">
    <source src="http://dict.youdao.com/dictvoice?type=0&amp;audio=analogue">
</video>
<script>
    const $ = (selector) => {
        return document.querySelector(selector)
    }

    const vscode = acquireVsCodeApi();
    window.addEventListener('message', event => {
        log('测试event', event.data)
        $('video').play()
        const word = event.data;
        const utterance = new SpeechSynthesisUtterance(word);
        speechSynthesis.speak(utterance);
        vscode.postMessage(event.data);
    });
</script>

但我研究发现好像vscode无法支持音频格式播放,microsoft/vscode#54097

这块有可解决的空间吗或者别的思路?

commented

经测试,采用audio可解决。