Slow TTS and duplicated voices

A lot of fixes here, thanks!

The new grouping in the deck options window and other graphical tweaks are great, I really think Anki looks much better now.

I’m not getting this error message when using built TTS in Windows, but most of the voices takes much longer (about 4 seconds) to start ( In previous versions all voices started instantly)

Edit: probably nothing to do with that problem, but just in case it may be a clue: using {{tts-voices:}} in 2.1.54 gives some duplicities:

But in 2.1.55 b7 there are way more duplicated entries:

1 Like

Strangely, I’ve gotten even more duplicated entries today (5 or 6 per voice) in b7, but after a little bit the lists is very similar to the list displayed in 2.1.54

The delay happens every time a card tries to play sound with all volices, except english american. Uninstalling and installing the microsoft voices doesn’t help.

Incidentally, when trying to use the TTS system with an uninstalled voice (for example the German voices), {{tts-voices:}} still show that voice in the list of availiable voices, even after restarting Anki:
image

But if I review and card using that voice, I get an error message and the built in TTS stops working at all (no sound in any card using TTS):

An error occurred. Please use Tools > Check Database to see if that fixes the problem.
If problems persist, please report the problem on our support site. Please copy and paste the information below into your report.
Anki 2.1.55 (fad1ff74) Python 3.9.15 Qt 6.4.0 PyQt 6.4.0
Platform: Windows-10-10.0.19044
Flags: frz=True ao=False sv=3
Add-ons, last update check: 2022-12-05 09:45:14
Caught exception:
Traceback (most recent call last):
File “aqt.taskman”, line 122, in _on_closures_pending
File “aqt.taskman”, line 71, in
File “aqt.sound”, line 295, in
File “aqt.tts”, line 589, in _on_done
File “concurrent.futures._base”, line 439, in result
File “concurrent.futures._base”, line 391, in __get_result
File “concurrent.futures.thread”, line 58, in run
File “aqt.sound”, line 295, in
File “aqt.tts”, line 585, in _play
File “asyncio.runners”, line 44, in run
File “asyncio.base_events”, line 647, in run_until_complete
File “aqt.tts”, line 616, in speakText
FileNotFoundError: [WinError -2147024894] El sistema no puede encontrar el archivo especificado

2.1.54 shows the “TTS system failed, please ensure Windows updates are installled, try restarting your computer or use a different voice” message instead.

Please run the following in the debug console. What does it print? How long does it take approximately?

import winsdk.windows.media.speechsynthesis as speechsynthesis
v = speechsynthesis.SpeechSynthesizer.get_all_voices() 
for v in v: 
  print(v.id, v.display_name, v.language) 

How long does the following take?

import asyncio
async def run():
    import winsdk.windows.media.speechsynthesis as speechsynthesis
    import winsdk.windows.storage.streams as streams
    s = speechsynthesis.SpeechSynthesizer()
    s.voice = s.get_all_voices()[0]
    stream = await s.synthesize_text_to_stream_async("hello world")
    inputStream = stream.get_input_stream_at(0)
    dataReader = streams.DataReader(inputStream)
    dataReader.load_async(stream.size)
    print(stream.size)
    for x in range(stream.size):
        _ = dataReader.read_byte()
asyncio.run(run())

The get_all_voices()[0] means to get the first voice from the list shown in the first step. If you change the number to match one of the slow voices in the list, presumably it is still slow?

https://docs.ankiweb.net/misc.html#debug-console

This is the output after running the first code, the answer is almost intantaneous and all installed voices appear, no duplicates:

The second one takes a lttle bit longer (2-3 secs). Changing s.voice = s.get_all_voices()[0] to s.voice = s.get_all_voices()[7] and running the resulting code doesn’t help: Hedda([7]) voice is still slow.

If you remove the two quoted lines above, is it still equally slow? What about if you remove the load_async line as well?

Unfortunately none of this fixes the problem, either using s.voice = s.get_all_voices()[0] or s.voice = s.get_all_voices()[7], if that helps.

Thanks for trying. I will try reverting to an older library in the next beta; please let me know how it goes for you.

1 Like

Thanks Damien, built -in TTS working OK here with RC1.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.