Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I set another output soundcard for "say" command? #27

Open
speedy-software-ch opened this issue Jan 13, 2018 · 3 comments
Open

Comments

@speedy-software-ch
Copy link
Contributor

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?

@KeenanTaggart
Copy link

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.

@KeenanTaggart
Copy link

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.

@rohitg00
Copy link

Try importing speechrecognition as sr in python
It is the best way to code desktop assisstant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants