def process_recognition(result, filename, output_directory, lexical):
    'Process recognition received from the speech service\n    Args:\n        result: Result object returned by STT-service\n        filename: Filename for output file\n        output_directory: Output directory for the file\n        lexical: Boolean to enable extended lexical version of STT-result\n    Returns:\n        text: Processed recognition as string\n    '
    if (result.reason == speechsdk.ResultReason.RecognizedSpeech):
        if lexical:
            text = f"{format(result.text)}	{json.loads(result.json)['NBest'][0]['Lexical']}"
        else:
            text = f'{format(result.text)}'
        logging.info(f'[INFO] - Recognition successful: {filename} -> {result.text}')
    elif (result.reason == speechsdk.ResultReason.NoMatch):
        logging.warning(((filename + '\t') + f'No speech could be recognized: {result.no_match_details}'))
        text = ''
    elif (result.reason == speechsdk.ResultReason.Canceled):
        cancellation_details = result.cancellation_details
        logging.error(((filename + '\t') + f'Speech Recognition canceled: {cancellation_details.reason}'))
        if (cancellation_details.reason == speechsdk.CancellationReason.Error):
            logging.error(f'Error details: {cancellation_details.error_details}')
        text = ''
    return text
Process recognition received from the speech service
Args:
    result: Result object returned by STT-service
    filename: Filename for output file
    output_directory: Output directory for the file
    lexical: Boolean to enable extended lexical version of STT-result
Returns:
    text: Processed recognition as string
def process_recognition(result, filename, output_directory, lexical):
    'Process recognition received from the speech service\n    Args:\n        result: Result object returned by STT-service\n        filename: Filename for output file\n        output_directory: Output directory for the file\n        lexical: Boolean to enable extended lexical version of STT-result\n    Returns:\n        text: Processed recognition as string\n    '
    if (result.reason == speechsdk.ResultReason.RecognizedSpeech):
        if lexical:
            text = f"{format(result.text)}	{json.loads(result.json)['NBest'][0]['Lexical']}"
        else:
            text = f'{format(result.text)}'
        logging.info(f'[INFO] - Recognition successful: {filename} -> {result.text}')
    elif (result.reason == speechsdk.ResultReason.NoMatch):
        logging.warning(((filename + '\t') + f'No speech could be recognized: {result.no_match_details}'))
        text = 
    elif (result.reason == speechsdk.ResultReason.Canceled):
        cancellation_details = result.cancellation_details
        logging.error(((filename + '\t') + f'Speech Recognition canceled: {cancellation_details.reason}'))
        if (cancellation_details.reason == speechsdk.CancellationReason.Error):
            logging.error(f'Error details: {cancellation_details.error_details}')
        text = 
    return text