#!/usr/bin/python3

import sys

from google_speech import Speech

if __name__ == "__main__":
    if len(sys.argv) <= 1:
        print("first argument is mising for the text to read")
        exit(0)
    text = sys.argv[1]
    if text in ['--help', '-h']:
        print('Usage : /google_sound "[text to read]" [.mp3 path] [optionnal lang : default "fr"]')
        print('')
        print('Common flags:')
        print(' -h   --help                   show usage information')
        exit(0)
    if len(sys.argv) == 2:
        print("a secong argument is missing : .mp3 path")
        exit(0)
    lang = "fr"
    if len(sys.argv) > 3:
        lang = sys.argv[3]
    speech = Speech(text, lang)

    # save the speech to an MP3 file (no effect is applied)
    speech.save(sys.argv[2])
