-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzinnengenerator_spraak.py
39 lines (36 loc) · 1.6 KB
/
zinnengenerator_spraak.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pyttsx3
import platform
import argparse
"""
PowerShell code to make the extra installed Narrator voices available to pyttsx3
$sourcePath = 'HKLM:\software\Microsoft\Speech_OneCore\Voices\Tokens' #Where the OneCore voices live
$destinationPath = 'HKLM:\SOFTWARE\Microsoft\Speech\Voices\Tokens' #For 64-bit apps
$destinationPath2 = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens' #For 32-bit apps
cd $destinationPath
$listVoices = Get-ChildItem $sourcePath
foreach($voice in $listVoices)
{
$source = $voice.PSPath #Get the path of this voices key
copy -Path $source -Destination $destinationPath -Recurse
copy -Path $source -Destination $destinationPath2 -Recurse
}
"""
# argumenten voor als code vanuit webinterface wordt aangeroepen
parser = argparse.ArgumentParser(description="Omschrijving: spreek de variabele uit")
parser.add_argument('--vertel', default='twee kilo bananen en een blik soep', help='spreek deze tekst uit')
args = parser.parse_args()
def VertelMij(text):
engine = pyttsx3.init()
voices = engine.getProperty('voices')
if platform.system() == 'Windows':
engine.setProperty('voice', voices[0].id) #for the default US Male voice
else:
#engine.setProperty('voice', voices[3].id) #for the default US Male voice
engine.setProperty('voice', 'dutch') #for the default US Male voice
engine.setProperty('voice', 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\MSTTS_V110_nlNL_Frank')
engine.setProperty('rate', 150)
#print(text)
engine.say(text)
engine.runAndWait()
#VertelMij("Twee kilo bananen en een blik soep")
VertelMij(args.vertel)