2

I have a small Python script that sets up PulseAudio such that the Festival speech synthesis program can pipe synthesised speech into Skype calls. This is to enable someone that is unable to speak to have a voice at regular Skype group meetings.

It works, but getting the setup to work involves a lot of interacting with the PulseAudio Volume Control GUI. How can the PulseAudio streams be set up by the script in the terminal?

The little script is as follows:

import os
import subprocess
import signal

def main():

    raw_input(
        "\nReady to load a dummy sound card driver...\n" +\
        "Press Enter to continue."
    )
    os.system("sudo modprobe snd-dummy")
    raw_input(
        "\nReady to set Festival running...\n" +\
        "Press Enter to continue."
    )
    process_Festival = subprocess.Popen(
        ["festival", "--tts", "/var/log/dmesg"],
        preexec_fn = os.setsid
    )
    raw_input(
        "\nReady to open PulseAudio Volume Control...\n" +\
        "Press Enter to continue.")
    os.system("pavucontrol &")
    raw_input(
        "\nIn PulseAudio Volume Control, select the tab \"Playback\".\n" +\
        "Identify Festival in operaton.\n" +\
        "Change the output sink of Festival to \"Dummy Analog Stereo\".\n" +\
        "Press Enter to continue."
    )
    raw_input(
        "\nReady to stop Festival running...\n" +\
        "Press Enter to continue."
    )
    os.killpg(os.getpgid(process_Festival.pid), 9)
    raw_input(
        "\nIn PulseAudio Volume Control, select the tab \"Recording\".\n" +\
        "Start a Skype call to \"Skype Test Call\".\n" +\
        "In PulseAudio Volume Control, identify Skype in operation.\n" +\
        "Change the input source of Skype to \"Monitor of Dummy Analog " +\
        "Stereo\"\n" +\
        "End the Skype call.\n" +\
        "Press Enter to continue."
    )
    raw_input(
        "\nReady for text entry speech synthesis broadcast to Skype...\n" +\
        "Press Enter to continue (and then make the Skype call when ready).\n"
    )
    while True:
        text = raw_input("> ")
        os.system("echo \"{text}\" | festival --tts".format(text = text))

if __name__ == "__main__":
    main()
d3pd
  • 7,935
  • 24
  • 76
  • 127

0 Answers0