Serialize the HTK model into a file.

    :param model: Model to be serialized

def serialize_model(model):
    """Serialize the HTK model into a file.

    :param model: Model to be serialized
    """

    result = ''

    # First serialize the macros
    for macro in model['macros']:
        if macro.get('options', None):
            result += '~o '
            for option in macro['options']['definition']:
                result += _serialize_option(option)

        elif macro.get('transition', None):
            result += '~t "{}"\n'.format(macro['transition']['name'])
            result += _serialize_transp(macro['transition']['definition'])

        elif macro.get('variance', None):
            result += '~v "{}"\n'.format(macro['variance']['name'])
            result += _serialize_variance(macro['variance']['definition'])

        elif macro.get('state', None):
            result += '~s "{}"\n'.format(macro['state']['name'])
            result += _serialize_stateinfo(macro['state']['definition'])

        elif macro.get('mean', None):
            result += '~u "{}"\n'.format(macro['mean']['name'])
            result += _serialize_mean(macro['mean']['definition'])

        elif macro.get('duration', None):
            result += '~d "{}"\n'.format(macro['duration']['name'])
            result += _serialize_duration(macro['duration']['definition'])

        else:
            raise NotImplementedError('Cannot serialize {}'.format(macro))

    for hmm in model['hmms']:
        if hmm.get('name', None) is not None:
            result += '~h "{}"\n'.format(hmm['name'])

        result += _serialize_hmm(hmm['definition'])

    return result