System.Speech in CPython3

After talking with a colleague that kinda knows python, he explained how IronPython2 likely had the System.Speech item preloaded and when I switched my node to CPython3, it didn’t know where to find that item b/c it’s not already preloaded. (or something like that lol)
I’ve changed the node back to IronPython2 and loaded that package and the script’s code works like it did in Dynamo 2.10. So I guess I’m good for now, but likely won’t be whenever they force us to give up IronPython2.
Thoughts, or can you tell me how to ‘load’ the system.speech item to get this to work in CPython3?

1 Like

Hello @adbryson
try this, (works on both engine)

import sys
import clr
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
from System.Speech.Synthesis import SpeechSynthesizer, VoiceGender, VoiceAge

greatBritainCulture = System.Globalization.CultureInfo("en-GB")
spk = SpeechSynthesizer()
spk.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Senior, 0, greatBritainCulture)
spk.SpeakAsync("Hello World on Dynamo")
5 Likes

that works perfectly, thanks @c.poupin !

2 Likes