-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import WinSDK | ||
import WindowsUtils | ||
import WinSDKExtras | ||
import CxxStdlib | ||
|
||
// Enable to run the full test, with a long message that will get cut off. | ||
let FULL_TEST = false | ||
|
||
// Use the win32 Speech API to convert text to speech | ||
class SpeechCommand: Command { | ||
private static let SPF_ASYNC = DWORD(1) | ||
private static let SPF_IS_NOT_XML = DWORD(1 << 4) | ||
|
||
func execute(_ arguments: [String]) throws { | ||
CoInitializeEx(nil, 0) | ||
defer { | ||
CoUninitialize() | ||
} | ||
|
||
var speak = SpeakApi() | ||
let flags: DWORD = SpeechCommand.SPF_ASYNC | SpeechCommand.SPF_IS_NOT_XML | ||
let message = FULL_TEST ? "Hello Fabric, Sandbox. This is a long message that will get cut off" : "" | ||
let result = speak.Speak(std.string(message), flags) | ||
guard result == S_OK else { | ||
throw Win32Error("Failed to speak", result: result) | ||
} | ||
|
||
if FULL_TEST { | ||
Sleep(2000) | ||
} | ||
|
||
speak.Skip() | ||
|
||
print("Spoke") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters