Skip to content

Instantly share code, notes, and snippets.

@7shi
Last active November 24, 2023 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7shi/ff7a7f6f2b04d436cc3bdee8a51e2db3 to your computer and use it in GitHub Desktop.
Save 7shi/ff7a7f6f2b04d436cc3bdee8a51e2db3 to your computer and use it in GitHub Desktop.
[はてなブログ] Speech Synthesis API のテンプレート
# 音声設定
音声の再生は環境に依存します。以下に選択肢が出ない言語は再生できません。
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/7shi/web-tts@0.11/speech.min.css">
<script src="https://cdn.jsdelivr.net/gh/7shi/web-tts@0.11/speech.min.js"></script>
<table id="voice_table"></table>
<script>
webTTS.initVoices({
ja: { name: "日本語", prefer: "Nanami Online", test: "こんにちは" },
en: { name: "英語", country: "US", test: "hello", pitch: 1 },
fr: { name: "フランス語", country: "FR", test: "bonjour", pitch: 1 },
}, voice_table);
</script>
# 読み上げ
漢字の誤読が見られる場合、`<span s="読み方">` で注釈を加えます。
<pre hidden><code id="source1">
これは<span s="なん"></span>ですか?
What is this?
Qu'est-ce que c'est ?
これはペンです。
This is a pen.
C'est un stylo.
</code></pre>
<table id="button1"></table>
<table id="text1"></table>
<script>
const source1Table = webTTS.convertSource(source1);
webTTS.initTable(source1Table, button1, text1, "ja", "en");
</script>
@7shi
Copy link
Author

7shi commented Feb 5, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment