Parse options and process text to Microsoft Translate

def main():
    """
    Parse options and process text to Microsoft Translate
    """

    # Parse arguments
    parser = OptionParser()
    parser.add_option('-n', '--subscription_key', dest='subscription_key',
                      help='subscription_key for authentication')
    parser.add_option('-t', '--text', dest='text',
                      help='text to synthesize')
    parser.add_option('-l', '--language', dest='language',
                      help='language')
    parser.add_option('-g', '--gender', dest='gender',
                      help='gender')
    parser.add_option('-d', '--directory', dest='directory',
                      help='directory to store the file')
    (options, args) = parser.parse_args()
    subscription_key = options.subscription_key
    text = options.text
    language = options.language
    gender = options.gender
    directory = options.directory

    # Perform sanity checks on options
    validate_options(subscription_key, text)

    if not directory:
        directory = default_directory

    if not language:
        language = default_language

    if not gender:
        gender = default_gender

    # format = 'riff-16khz-16bit-mono-pcm'
    format = 'riff-8khz-8bit-mono-mulaw'

    # lang = 'en-AU'
    # gender = 'Female'
    tts_msspeak = MSSpeak(subscription_key, '/tmp/')
    tts_msspeak.set_cache(False)
    output_filename = tts_msspeak.speak(text, language, gender, format)

    print 'Recorded TTS to %s%s' % (directory, output_filename)