summaryrefslogtreecommitdiff
path: root/tools/sapi5_voice_new.vbs
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-09-01 08:38:10 +0000
committerJens Arnold <amiconn@rockbox.org>2007-09-01 08:38:10 +0000
commit080522f9173526c9ffca06bf12782ddf73cb577a (patch)
tree56c39cb41ef1bfe1f933e35cc11b7aa926d3e13f /tools/sapi5_voice_new.vbs
parent80e91c1af392c72cd72095c1cbfa21957462381b (diff)
downloadrockbox-080522f9173526c9ffca06bf12782ddf73cb577a.tar.gz
rockbox-080522f9173526c9ffca06bf12782ddf73cb577a.zip
Voice file generation: * Significant speedup of SAPI5 voice generation by running lame and wavtrim from inside the VB script instead of the perl script, avoiding the large overhead of process generation within cygwin. Added proper synchronisation between perl script and VB script as the pipes are buffered. * Make wavtrim work as intended (threashold wasn't passed). * Set correct SVN properties for the VB script.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14562 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/sapi5_voice_new.vbs')
-rwxr-xr-xtools/sapi5_voice_new.vbs69
1 files changed, 48 insertions, 21 deletions
diff --git a/tools/sapi5_voice_new.vbs b/tools/sapi5_voice_new.vbs
index 96c6e2a720..f6abcf7d0b 100755
--- a/tools/sapi5_voice_new.vbs
+++ b/tools/sapi5_voice_new.vbs
@@ -20,11 +20,13 @@
20 20
21'To be done: 21'To be done:
22' - Allow user to override voice, speed and/or format (currently uses Control Panel defaults for voice/speed) 22' - Allow user to override voice, speed and/or format (currently uses Control Panel defaults for voice/speed)
23' - Voice specific replacements/corrections for pronounciation (this should be at a higher level really) 23
24Option Explicit
24 25
25Const SSFMCreateForWrite = 3 26Const SSFMCreateForWrite = 3
26 27
27Const SPSF_8kHz16BitMono = 6 28' Audio formats for SAPI5 filestream object
29Const SPSF_8kHz16BitMono = 6
28Const SPSF_11kHz16BitMono = 10 30Const SPSF_11kHz16BitMono = 10
29Const SPSF_12kHz16BitMono = 14 31Const SPSF_12kHz16BitMono = 14
30Const SPSF_16kHz16BitMono = 18 32Const SPSF_16kHz16BitMono = 18
@@ -34,34 +36,59 @@ Const SPSF_32kHz16BitMono = 30
34Const SPSF_44kHz16BitMono = 34 36Const SPSF_44kHz16BitMono = 34
35Const SPSF_48kHz16BitMono = 38 37Const SPSF_48kHz16BitMono = 38
36 38
37Dim oSpVoice, oSpFS, nAudioFormat, sText, sOutputFile 39Dim oShell, oEnv
40Dim oSpVoice, oSpFS ' SAPI5 voice and filestream
41Dim aLine, aData ' used in command reading
42Dim nAudioFormat
43Dim bVerbose
44
45
46On Error Resume Next
38 47
39nAudioFormat = SPSF_22kHz16BitMono 'Audio format to use, recommended settings: 48nAudioFormat = SPSF_22kHz16BitMono 'Audio format to use, recommended settings:
40'- for AT&T natural voices, use SPSF_32kHz16BitMono 49'- for AT&T natural voices, use SPSF_32kHz16BitMono
41'- for MS voices, use SPSF_22kHz16BitMono 50'- for MS voices, use SPSF_22kHz16BitMono
42 51
52Set oShell = CreateObject("WScript.Shell")
53Set oEnv = oShell.Environment("Process")
54bVerbose = (oEnv("V") <> "")
55
43Set oSpVoice = CreateObject("SAPI.SpVoice") 56Set oSpVoice = CreateObject("SAPI.SpVoice")
44If Err.Number <> 0 Then 57If Err.Number <> 0 Then
45 WScript.Echo "Error - could not get SpVoice object. " & _ 58 WScript.StdErr.WriteLine "Error - could not get SpVoice object. " & _
46 "SAPI 5 not installed?" 59 "SAPI 5 not installed?"
47 Err.Clear 60 Err.Clear
48 WScript.Quit 1 61 WScript.Quit 1
49End If 62End If
50 63
51While 1 > 0 64Set oSpFS = CreateObject("SAPI.SpFileStream")
52 sText = WScript.StdIn.ReadLine 65oSpFS.Format.Type = nAudioFormat
53 sOutputFile = WScript.StdIn.ReadLine 66
54 If sOutputFile = "" Then 67On Error Goto 0
55 Set oSpFS = Nothing 68
56 Set oSpVoice = Nothing 69Do
57 Set oArgs = Nothing 70 aLine = Split(WScript.StdIn.ReadLine, vbTab, 2)
58 WScript.Quit 0 71 If Err.Number <> 0 Then
72 WScript.StdErr.WriteLine "Error " & Err.Number & ": " & Err.Description
73 WScript.Quit 1
59 End If 74 End If
60 ' WScript.Echo "Saying " + sText + " in " + sOutputFile 75 Select Case aLine(0) ' command
61 Set oSpFS = CreateObject("SAPI.SpFileStream") 76 Case "SPEAK"
62 oSpFS.Format.Type = nAudioFormat 77 aData = Split(aLine(1), vbTab, 2)
63 oSpFS.Open sOutputFile, SSFMCreateForWrite, False 78 If bVerbose Then WScript.StdErr.WriteLine "Saying " & aData(1) _
64 Set oSpVoice.AudioOutputStream = oSpFS 79 & " in " & aData(0)
65 oSpVoice.Speak sText 80 oSpFS.Open aData(0), SSFMCreateForWrite, false
66 oSpFS.Close 81 Set oSpVoice.AudioOutputStream = oSpFS
67Wend 82 oSpVoice.Speak aData(1)
83 oSpFS.Close
84 Case "EXEC"
85 If bVerbose Then WScript.StdErr.WriteLine "> " & aLine(1)
86 oShell.Run aLine(1), 0, true
87 Case "SYNC"
88 If bVerbose Then WScript.StdErr.WriteLine "Syncing"
89 WScript.StdOut.WriteLine aLine(1) ' Just echo what was passed
90 Case "QUIT"
91 If bVerbose Then WScript.StdErr.WriteLine "Quitting"
92 WScript.Quit 0
93 End Select
94Loop