jdlorimer/chinese-support-redux

Plugin requests incorrect string to speech engine

Opened this issue · 3 comments

Describe the bug
Speech engine downloads a file with the sound: span class=cmn_tone4菜span_baidu_zh.mp3, instead of just 菜_baidu_zh.mp3. It reads the whole thing, instead of just the character. Same thing happens with Google Translate.

To Reproduce

  • So I'm using the Hanping HSK deck from Ankiweb shared decks (https://ankiweb.net/shared/info/1907668496). What I want to do is create a new card type with an audio file to train listening.
  • I rename the "Simplified" field to "Hanzi" so the plugin will recognize it, and I add a "Sound" field.
  • I bulk fill the sound without problem.
  • All files include the "span class=cnm..." bit, so the file is unusable for listening practice.

Expected behavior
Getting just the characters pronunciation, not the rest.

Specs

  • OS: Windows 10
  • Anki Version 2.1.33
  • Chinese Support Version 0.14.0

Additional context
I tried deleting everything in the card front, back and styling, in case the plugin was getting the string for the speech engine from there. It didn't change anything. Using the Basic or Advanced templates works perfectly, but I want to use this deck, since I like its formatting and other features.

Thanks in advanced for the help!

I have the same issue! Have you found a solution?

Well, since I couldn't find a solution and there was no reply here I had desisted and moved on, tbh. It seems the problem is that the plugin is requesting the HTML code and not the stripped text and there is no way to tell the plugin to use {{text:Simplified}}, afaik.

However, since I added many other plugins recently, I just checked, and using AwesomeTTS (v1.13.0-dev) works perfectly without any specific configuration. I recommend Google Cloud Text-to-Speech with a Wavenet voice. (You probably need a free API, instructions are on AwesomeTTS unofficial webpage). You can give it a try.

It's hard to know whether to classify this as a just a bug, or a philosophical difference with unexpected consequences.

The reason the Basic and Advanced note types work is because all formatting is done via CSS in the actual template, rather than embedding it in the fields. This is the more flexible approach and allows easy bulk changes to formatting.

It also means that you can embed English words in Chinese sentences (as often occurs in casual written Chinese) and have the TTS engine read those out.

That said, I'll make sure the HTML gets stripped out, because that's obviously an issue. What to do about other content, I'm not so sure.