# Slow TTS and duplicated voices

**URL:** <https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157>\
**Category:** Beta Testing\
**Created:** [December 4, 2022, 9:32pm UTC](https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157 "2022-12-04T21:32:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cqg](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@cqg](https://forums.ankiweb.net/u/cqg)\
**Post date:** [December 4, 2022, 9:32pm UTC](https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157/1 "2022-12-04T21:32:32Z")

</div>

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](https://forums.ankiweb.net/t/anki-2-1-55-beta-5-6/24870/42) 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:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/2/2331237be4bcea409e9ff7956678ad1620496bee.png)

But in 2.1.55 b7 there are way more duplicated entries:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/9/9de7dd38d5c8303292fcc6d83949618ee3576533.png)

---

<div class="post-metadata">

**Author:** ![cqg](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@cqg](https://forums.ankiweb.net/u/cqg)\
**Post date:** [December 5, 2022, 9:07am UTC](https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157/2 "2022-12-05T09:07:17Z")

</div>

> [@Anki 2.1.55 Beta 7 / RC1 / RC2](https://forums.ankiweb.net/t/anki-2-1-55-beta-7-rc1-rc2/25130/8):
>
> I’m not seeing any duplicates here. Does the delay to start only happen on the first audio, or does it happen every time a card tries to play sound?

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](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/4/44f472ccc54b25cea39655aa16de6924a8ec2874.png)

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.

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [December 5, 2022, 11:33am UTC](https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157/3 "2022-12-05T11:33:29Z")

</div>

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

```auto
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?

```auto
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](https://docs.ankiweb.net/misc.html#debug-console)

---

<div class="post-metadata">

**Author:** ![cqg](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@cqg](https://forums.ankiweb.net/u/cqg)\
**Post date:** [December 5, 2022, 11:56am UTC](https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157/4 "2022-12-05T11:56:04Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/d/da2e2d9a53685fb9f09f2ed99cc57fa60b3e01ee.png)

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.

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [December 5, 2022, 12:38pm UTC](https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157/5 "2022-12-05T12:38:28Z")

</div>

> [@dae](#):
>
> ```auto
> for x in range(stream.size):
> _ = dataReader.read_byte()
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![cqg](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@cqg](https://forums.ankiweb.net/u/cqg)\
**Post date:** [December 5, 2022, 1:06pm UTC](https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157/6 "2022-12-05T13:06:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [December 6, 2022, 10:25am UTC](https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157/7 "2022-12-06T10:25:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cqg](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@cqg](https://forums.ankiweb.net/u/cqg)\
**Post date:** [December 12, 2022, 9:08am UTC](https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157/8 "2022-12-12T09:08:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [January 11, 2023, 9:09am UTC](https://forums.ankiweb.net/t/slow-tts-and-duplicated-voices/25157/9 "2023-01-11T09:09:37Z")

</div>

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