Last active
September 20, 2022 18:24
-
-
Save spencerkittleson/4245a751c15faa32fa764982f542f886 to your computer and use it in GitHub Desktop.
AHK Text to Speech Everywhere!
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
// See https://aka.ms/new-console-template for more information | |
using SynthesizerAudio; | |
using System.Media; | |
var cts = new CancellationTokenSource(); | |
cts.CancelAfter(TimeSpan.FromSeconds(10)); | |
var text = string.Empty; | |
if (args.Length > 0 && File.Exists(args[0])) { | |
text = await File.ReadAllTextAsync(args[0], cts.Token) ?? string.Empty; | |
} else { | |
Environment.Exit(1); | |
} | |
var audioService = new SynthesizerWebAudioService(); | |
var audio = await audioService.TextToSpeechAudioAsync(text, new TextToSpeechAudioOptions { | |
Format = SynthesizerAudio.SynthesizerWebAudioService.AUDIO_FORMAT.WAV, | |
VoiceName = "Zira", | |
}); | |
using var player = new SoundPlayer { Stream = audio }; | |
player.Load(); | |
player.PlaySync(); | |
Environment.Exit(0); |
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
#c:: | |
FileDelete,clip.txt | |
Process, Close, UserTriggerTextToSpeech.exe | |
Sendinput, ^{c} ; copy the selected text/item/whatever | |
Sleep 500 | |
clipwait, 2,1 | |
Current_Clipboard := Clipboard | |
FileAppend,%Current_Clipboard%,clip.txt | |
Run, UserTriggerTextToSpeech.exe clip.txt, , Hide | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment