Open speedy-software-ch opened 6 years ago
I did a bit of investigation to try to find a solution. I have a few leads but I'm not sure if any of them will work at present.
I downloaded the source files for gnustep-gui-runtime and took a look at the source code for say. It's written in Objective-C (which I'm not particularly familiar with) and uses the associated sound interfaces (NSSpeechSynthesizer and NSSound). I.e. it creates a speech object
NSSpeechSynthesizer *say;
and then actually does the speech here
if (nil != outFile)
{
[say startSpeakingString: words toURL: [NSURL fileURLWithPath: outFile]];
}
else
{
[say startSpeakingString: words];
}
The documentation for NSSpeechSynthesizer is here where it states it outputs sound through the "system's default sound output device" but doesn't indicate how to find/change that. The NSSound documentation has more clues since it features a playbackDeviceIdentifier
and allegedly a function to setPlaybackDeviceIdentifier
.
The remaining problem presumably would be actually finding the device identifiers on your system and then adding the ability to change that to the say source files.
This is just a guess, but maybe the "default sound output device" on Linux would be pulled from PulseAudio? @speedy-software-ch maybe you can try (if you haven't already) setting a default audio device in /etc/pulse/default.pa by adding the line set-default-sink #
with the index number of the device you want.
It feels like a long shot, but I don't know where else it would be getting a system default from.
Try importing speechrecognition as sr in python It is the best way to code desktop assisstant
On my laptop "say" command works as intended even though i have two sound outputs (Normal and HDMI audio). Due to me recording and producing music too, on my desktop PC i have the normal Soundcard installed in the Tower (which i don't use), and an external one connected over USB. I can switch to which device i wanna use in ubuntu over pulseaudio selection, or even alsa, but it doesn't change which soundcard "say" command is using for output. Is there a way to define that somewhere? if yes maybe we could even add that as a feature to Virtual-Assistant. Help anyone?