Commit abc599d5 authored by Aleš Horák's avatar Aleš Horák
Browse files

record TTS outpus to file

parent 1d87d208
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ import argparse
import qi
import sys

def main(ip, port, language, volume, text):
def main(ip, port, language, volume, tofile, text):
    s = qi.Session()
    s.connect("tcp://"+str(ip)+":"+str(port))
    # Get proxies
@@ -25,6 +25,10 @@ def main(ip, port, language, volume, text):
    print "Text is '{}' (in {})".format(text, language)
    sys.stdout.flush()
    audio.setOutputVolume(volume)
    if tofile is not None:
        tts.sayToFile(text, tofile)
        print "Saved to '{}'".format(tofile)
    else:
        anim.say(text)
    if language != cur_lang: tts.setLanguage(cur_lang)

@@ -36,6 +40,7 @@ if __name__ == "__main__":
    parser.add_argument("--port", type=int, default=9559, help="Robot port number")
    parser.add_argument("--language", type=str, help="Language to use (default depends on robot settings)")
    parser.add_argument("--file", type=str, help="Read the text from file")
    parser.add_argument("--tofile", type=str, help="Write the output sound to a WAV file")
    parser.add_argument("--volume", type=int, default=50, help="Set volume percentage")

    args = parser.parse_args()
@@ -43,4 +48,4 @@ if __name__ == "__main__":
    if args.file is not None:
        with open(args.file, 'r') as myfile:
            text = myfile.read() + text
    main(args.ip, args.port, args.language, args.volume, text)
    main(args.ip, args.port, args.language, args.volume, args.tofile, text)