The original Advanced Context Sentence userscript by @abdullahalt is not maintained anymore, so I decided to take over maintenance.
Install Advanced Context Sentence 2
General script installation guide
Optional: Open Framework installation
Optional: Open Framework JLPT, Joyo, and Frequency filters
Do not forget to uninstall the old Advanced Context Sentence script if you have it installed.
(The following description is partially copied from the original script’s thread)
This script enhances the example sentences provided by WaniKani with the following features:
Recognizable Kanji Highlighting
Highlights the kanji you already learned and should be able to recognize. This will encourage you to read the context sentence just to try and remember all the kanji you learned in it.
Forgot the kanji? Just click on it and you will be taken to the kanji’s item page to review it again.
Adds an audio button that uses voice synthesis to read the Japanese sentence. By default, this uses the voice synthesizer provided by your webbrowser, but it can be changed in the settings to use the Google Translate voice synthesizer. Keep in mind that neither of the two options will deliver perfect results.
Hovering over kanji will reveal some information about the kanji like the WaniKani level, readings, and meanings. Additionally, using the Open Framework JLPT, Joyo, and Frequency filters, Advanced Context Sentence can show you JLPT level, Joyo level, and frequency of that kanji.
Note: you will only get information if the kanji is on Wanikani, if not then the link will take you to the kanji page on Jisho.org and you can get all the information you need from there.
Weblink to a Sentence Segmenter
Optionally adds a link to send the sentence to a webpage of your choice. By default, the sentence is sent to ichi.moe which will segment the sentence into phrases/words and show each word’s translation.
I updated the entry in the scripts list to point to this thread
Cool new feature with the link to ichi.moe. I’ve used it before when I’m reading books but it makes sense to have it attached to these context sentences.
Thank you very much! The old script stopped working for me a while ago, now your update is back on. Nice touch with ichi.moe!
Very useful, thank you for updating the script!
Do you think it would be possible to add Voicevox TTS to the script somehow? Here’s the link to its Github website with the engine/core.
They don’t offer an online API, it’s just a tool you can download – I don’t think it is possible to utilize this in a userscript.
Allow to select from the list of Japanese synthetic voices that the browser supports
Until now, when using the speech synthesis provided by the browser, the script would just tell the API that it wants to have a Japanese voice without further specification. Now, the user can choose from a list of all voices available in their browser.
The available options may vary between different browsers: On Windows 10, Edge offers me Ayumi, Haruka, Ichiro, and Sayaka as local voices (all with low quality results) and Nanami as online voice (very good quality). Chrome offers the same four local voices and Google 日本語 as online voice (also of disappointing quality). Firefox only finds Haruka and also does not add any online options.
Microsoft Nanami is the only voice available to me that actually manages to read はやく中に入ろう。 correctly.
Please let me know if something doesn’t work.
Link to previous script version for downgrading in case version 2.1 doesn’t work for you
Really good app, but the volume absolutely destroys my ears because it plays it as full blast compared to everything else on my PC.
Is there a way to have a slider for it?
I have now added a volume slider to the settings menu
Added a volume setting
A slider located in the settings menu. To use the settings menu, you need Open Framework installed.
New functionality: Highlight currently read sentence section
While searching for volume controls for the synthetic speech, I stumbled upon the sentence
If SSML is used, this value will be overridden by prosody tags in the markup.
Looking into SSML, it stands for “Speech Synthesis Markup Language”, and if I understand correctly, it would allow to use “furigana” to tell the speech synthesizer which reading to use. Sadly, SSML seems to not be supported by webbrowsers. But I stumbled upon a webpage that showcased another interesting feature: highlighting the word that is currently read. I thought this could be an interesting addition to “Advanced Context Sentence 2”.
This feature is not available for the Google Translate voice.
Please let me know if something doesn’t work.
Link to previous script version for downgrading in case version 2.3 doesn’t work for you
Gotta lookup SSML not only for Furigana, but also for pitch accent. (Still, it requires setting up a TTS server, and some subscription, which I already have Azure anyway.)
It is possible and probably not too hard in Azure, but it requires knowing more than Kana reading or Furigana.
In w3c, there is
<xhtml:rt role="alphabet:x-JEITA">, but not sure how well it works, nor can I find documentations, and which TTS support this one at all? (Google and Amazon appear to only have IPA and X-SAMPA.)
Where would you get Furigana data, anyway, other than handmade? Even Furigana inserter isn’t that accurate. It is of course possible by personal doing, but not sure about sharing / community.
Forgot to say about Web Speech API. It might require setting up? Adding Japanese keyboard in Windows, but much easier in Mac. For Linux it depends, but probably need espeak and some troubleshooting?
I did not say that I wanted to use SSML in “Advanced Context Sentence 2” – I was just looking into it out of general curiosity if it could potentially be used in any userscript. That said, it might also have been possible to use it in “Advanced Context Sentence 2”: For example with the context sentence “はやく中に入ろう。” for the vocab item 中, the only occurrence of 中 in the sentence would have to be read with the reading provided by WK. This could have been useful to prevent some speech synthesizers from reading it as ちゅう.
But anyway, as there is no browser support I didn’t look any further into it.
At least Google Chrome and Microsoft Edge (on Windows 10) seem to support Japanese online voices without any need for setup. I think Firefox does not and only finds one local Japanese voice; but even if the webbrowser does not provide any Japanese voices, “Advanced Context Sentence” still provides the Google Translate voice as an alternative.