AwesomeTTS / awesometts-anki-addon

AwesomeTTS text-to-speech add-on for Anki
GNU General Public License v3.0
484 stars 100 forks source link

Add opus support #189

Open luc-vocab opened 3 years ago

luc-vocab commented 3 years ago

Could you add support for opus instead of mp3? it gives a lot better quality audio from Google TTS. I've changed the line in googletts.py from "audioEncoding": "MP3" to "audioEncoding": "OGG_OPUS" it gives opus but AwesomeTTS gives wrong extension mp3 to it even thought is opus. Anki on desktop can still play it even with wrong extension but not on mobile. So please fix it and allow to change it to opus.ogg for maximum compatibility (android 7 requires opus.ogg to play opus files)

barolo commented 2 years ago

I would like to see it added to, for Watson too.

Yutsuten commented 2 years ago

Very hacky and probably breaks other services, but you can change awesometts/router.py line 891 to change the extension to .ogg:

(return value of def _path_cache)

 return os.path.join(
     self._cache_dir,
     '.'.join([
         '-'.join([
             svc_id, hex_digest[:8], hex_digest[8:16],
             hex_digest[16:24], hex_digest[24:32], hex_digest[32:],
         ]),
-        'mp3',
+        'ogg',
     ]),
 )
luc-vocab commented 2 years ago

FYI HyperTTS supports ogg, would you be willing to give it a try ?

Yutsuten commented 2 years ago

I am trying both actually. And email'd you about an issue I had https://github.com/Language-Tools/anki-hyper-tts/issues/80

But HyperTTS don't have the preview window I am used to use, and editing existing presets wasn't as smooth as I was expecting. I feel AwesomeTTS is better at this point... Maybe I just not tried it enough?

Anyway, I'm still wondering which one to use.

luc-vocab commented 2 years ago

HyperTTS is much much better at giving you a preview for multiple notes, and much more predictable with things like text replacement. Which preview window are you referring to ?

Yutsuten commented 2 years ago

HyperTTS is much much better at giving you a preview for multiple notes

If you mean batch editing, I do not use this feature in my workflow.

much more predictable with things like text replacement. Which preview window are you referring to ?

This one:

20221118-205402447_grim

My use case: I add speech to Japanese sentences. Not sure if you know, but a single Japanese kanji may have several readings. Sometimes Google TTS mistakes the pronunciation and then I have to replace the kanji with its reading in hiragana. But this replacement is only to get the correct pronunciation for the specific sentence, and I want to keep my original sentence with the kanji.

With AwesomeTTS I replace the kanji with its reading in the preview window.

With HyperTTS I fell that it forces me to either:

  1. Replace the kanji with hiragana in the field that contains the sentence, generate the speech with Google TTS, and then change back the sentence with kanji
  2. Add a global text replacement that will replace the kanji with hiragana EVERY time, which will give problems on another sentences

If the "preview for multiple notes" you mentioned in your comment gives me such preview window, I may have overlooked the feature.

We can continue this discussion somewhere else (I'd love to see where it will end up) to not spam this issue, if you want.